PHP警告:ftp_put():超时。同时上传大于1 mb的压缩文件

时间:2017-11-27 05:54:56

标签: php timeout

我想将文件上传到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;
            }
        }

Log

0 个答案:

没有答案