选择语言 :

 Core_Ftp::upload

上传文件

bool Core_Ftp::upload( string $locpath , string $rempath [, string $mode = string(4) "auto" , int $permissions = null ] )

参数列表

参数 类型 描述 默认值
$locpath string
$rempath string
$mode string string(4) "auto"
$permissions int null
返回值
  • bool
File: ./core/classes/ftp.class.php
public function upload($locpath, $rempath, $mode = 'auto', $permissions = null)
{
	if (!$this->_is_conn())
	{
		return false;
	}

	if (!file_exists($locpath))
	{
	    if (IS_DEBUG)
	    {
	        Core::debug()->error(__('ftp no source file'));
	    }
	    return false;
	}

	// 设置权限
	if ($mode === 'auto')
	{
		// 获取上传文件的类型
		$ext  = $this->_getext($locpath);
		$mode = $this->_settype($ext);
	}

	$mode = ($mode === 'ascii') ? FTP_ASCII : FTP_BINARY;

	$result = @ftp_put($this->_conn_id, $rempath, $locpath, $mode);

	if (false===$result)
	{
		if (IS_DEBUG)
		{
			Core::debug()->error(__('ftp unable to upload'));
		}
		return false;
	}

	// Set file permissions if needed
	if (!is_null($permissions))
	{
		$this->chmod($rempath, (int)$permissions);
	}

	return true;
}