[Solved] Using file_get_contents and ftp_put [closed]


ftp_put expects a path to a local file as its third argument, not the contents of the file like you are passing it here:

$current = file_get_contents($file);
// Append a new person to the file
$current .= "John Smith\n";

...

$local_file = $current;

...

$upload = ftp_put($conn_id, $ftp_path, $local_file, FTP_ASCII);

You will probably want to do something like this:

$fp = fopen('php://temp', 'r+');
fputs($fp, $current);
rewind($fp); // so that we can read what we just wrote in

// Using ftp_fput instead of ftp_put -- also, FTP_ASCII sounds like a bad idea
$upload = ftp_fput($conn_id, $ftp_path, $fp, FTP_BINARY);
fclose($fp); // we don't need it anymore

0

solved Using file_get_contents and ftp_put [closed]