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!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Linux new version
SublimeText3 Linux latest version

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

Atom editor mac version download
The most popular open source editor