I'm trying to FTP a string value as a file without writing it to the local server as a file, but I can't get ftp_put() to work. If I read a file from the server, ftp_fput() works:

$fh = fopen("test.txt", "r");
$upload = ftp_fput($conn_id, $destination_file, $fh, FTP_ASCII);
if(!$upload) {
        echo "<p>FTP upload has failed!</p>\n";
} else {
        echo "<p>Uploaded to ".$ftp_server." as ".$destination_file."</p>\n";
}

But trying to avoid writing to the local server by using ftp_put() instead, this does not work:

$source = "This is a test file. This is a test file.\nThis is a test file.";
$upload = ftp_put($conn_id, $destination_file, $source, FTP_ASCII);


I don't understand why ftp_put() isn't able to use $source as a string value, but substituting ftp_fput() into the script and using a file handle does work. I'm trying to avoid writing a file to the local server just to be able to use ftp_fput().

--
Lowell Allen

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to