我想将文件上传到ftp服务器,但问题是当我尝试上传超过1 mb的压缩文件时会抛出错误。没有压缩我上传了一个60 MB的文件。这是我的代码。
// *** Set up basic connection
$this->connectionId = ftp_connect($server, $port = $port);
// *** Login with username and password
$loginResult = ftp_login($this->connectionId, $ftpUser, $ftpPassword);
// *** Sets passive mode on/off (default off)
ftp_pasv($this->connectionId, $isPassive);
// *** Check connection
if ((!$this->connectionId) || (!$loginResult)) {
$this->logMessage('FTP connection has failed!');
$this->logMessage('Attempted to connect to ' . $server . ' for user ' . $ftpUser, true);
return false;
} else {
$this->logMessage('Connected to ' . $server . ', for user ' . $ftpUser);
$this->loginOk = true;
return true;
}
public function uploadFile($fileFrom, $fileTo)
{
$fileTo = 'Magento Exporter/' . $fileTo;
$mode = FTP_BINARY;
// *** Upload the file
try {
$upload = ftp_put($this->connectionId, $fileTo, $fileFrom, $mode);
} catch (Exception $exception) {
echo $exception;
}
// *** Check upload status
if (!$upload) {
$this->logMessage('FTP upload has failed!');
return false;
} else {
print_r(error_get_last());
$this->logMessage('Uploaded "' . $fileFrom . '" as "' . $fileTo . '"');
return true;
}
}