Ftp_put working for month, now has stopped?

Asked
Active3 hr before
Viewed126 times

5 Answers

working
90%

This fixed it for me. I was dealing with FTP backup code that had stopped working after bumping PHP version. Enabling passive mode after using ftp login did the trick. – John Nov 13 '16 at 19:49 , Thanks. yes I did try that, did a manual transfer with filezilla using same ftp credentials and it worked 100%. Just the php component failing and I am not sure why. Thanks again. – JustStarting Jul 25 '13 at 10:27 , Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers ,EDIT: Found a workaround, not sure it will work for anyone as it involves SSL connection, the bad thing is it was working fine until last PHP update (updated to 5.6.14)

You could try to switch to passive mode (set it to true):

ftp_pasv($conn, true);
88%

An FTP\Connection instance., ftp_put() stores a local file on the FTP server. ,ftp_nb_put() - Stores a file on the FTP server (non-blocking),ftp_put — Uploads a file to the FTP server

load more v
72%

PHP ftp_put fails with "Warning: ftp_put (): PORT command successful",my article on the active and passive FTP connection modes.,Now, the question is why PHP uses PORT, when you asked it to connect using passive mode (ftp_pasv).,For a similar issue (just with ProFTPd), see: PHP ftp_put returning "Unable to build data connection: Connection refused"

This is what I have so far:

public
function echo_contents() {
   $file = fopen('php://output', 'w+');

   if (!$file) {
      throw new Exception('Unable to open output');
   }

   try {
      $this - > ftp - > get($this - > path, $file);
   } catch (Exception $e) {
      fclose($file); // wtb finally               

      throw $e;
   }

   fclose($file);
}

$this->ftp->get looks like this:

public
function get($path, $stream) {
   ftp_fget($this - > ftp, $stream, $path, FTP_BINARY); // Line 200
}
load more v
65%

Below examples illustrate the use of ftp_put() function in PHP:Example 1:  ,The following examples cannot be run on online IDE. So try to run in some PHP hosting server or localhost with proper ftp server name.,PHP | ftp_put() function,PHP | ftp_delete() function

The ftp_put() function is an inbuilt function in PHP which is used to upload files to FTP server.
Syntax: 
 

ftp_put($ftp_connection, $remote_file_path, $local_file_path, $mode, $start_position);

Output: 
 

Successfully connected to the ftp server!
   logged in successfully!
   Uploaded successful filetoupload.txt.
Connection closed Successfully!

Output: 
 

Successfully connected to the ftp server!
   logged in successfully!
   Uploaded successful filetoupload.txt.
Connection closed Successfully!
load more v
75%

load more v

Other "working-undefined" queries related to "Ftp_put working for month, now has stopped?"