link,true);" method to switch to passive mode; finally re-upload the file on the client. Can."/> link,true);" method to switch to passive mode; finally re-upload the file on the client. Can.">
search
HomeBackend DevelopmentPHP ProblemWhat to do if php ftp_put fails

What to do if php ftp_put fails

Jul 24, 2020 am 11:12 AM
ftp_put

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.

What to do if php ftp_put fails

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

DVWA

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