php Solution to ftp_put failure: First open "Upload/Driver/Ftp.class.php"; then use the "ftp_pasv($this->link,true);" method to switch to passive mode; finally Just re-upload the file on the client.
Recommended: "PHP Tutorial"
PHP Upload FTP driver ftp_put function upload failure problem
2 servers, one for ftp server and one for web server.
I use the Upload class of thinkphp3.2 and use the upload FTP driver, but it says file saving failure every time.
I am looking for the answer. I have tested both asynchronous and synchronous, but neither works. The remote /tmp/ and ftp directories also have 777 permissions.
Thinkphp should be very mature. Later I found some answers in the official documents, including the explanation mode
ftp server active mode, ftp server passive mode, I use ftp_pasv($this-> ;link,true); Switch to passive mode and the client can upload files smoothly.
Here is the solution
Upload/Driver/Ftp.class.php sava function
public function save($file, $replace=true) { $filename = $file['rootPath']. $file['savepath'] . $file['savename']; /* 不覆盖同名文件 */ // if (!$replace && is_file($filename)) { // $this->error = '存在同名文件' . $file['savename']; // return false; // } ftp_pasv($this->link,true); ftp_pwd($this->link); $filename=$file['savename']; if (!ftp_put($this->link, $filename, $file['tmp_name'],FTP_ASCII)) { $this->error = '文件上传FTP错误!'; return false; } return true; }
The above is the detailed content of What to do if php ftp_put fails. For more information, please follow other related articles on the PHP Chinese website!