note 45761 deleted from function.ftp-put by nlopess

From: Date: Fri, 17 Sep 2004 15:06:31 +0000
Subject: note 45761 deleted from function.ftp-put by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76885@lists.php.net to get a copy of this message
Note Submitter: liuk AT fanwars DOT it ---- I'm not pretty sure about this, but after may tries I'm forced to believe that the "$destination_file" parameter in the function is not to be used to rename the file you are uploading. On the other hand I think it's a variable in which the function puts the name the remote file has after the upload. I am not pretty sure about this, but I wrote this simple script to make a try: <?php require("config.php"); // File containing connection information $connection = @ftp_connect ($ftp_server,$ftp_port); $ftp_login = @ftp_login ($connection,$ftp_username,$ftp_password); if (!$connection || !$ftp_login) { $error = "Connection error"; } switch ($action) { case "upload": $location = "/remotepath/upload"; ftp_chdir($connection,$location); $result = @ftp_put($connection, $upload_file_name, $upload_file, FTP_BINARY); $info = ($result == 1 ? "File successfully uploaded!" : "Upload error!"); echo $info; break; default: echo "<form enctype=\"multipart/form-data\" method=\"post\">\n" ."<br><b>Carica un File:</b><br>\n" ."<input type=\"file\" name=\"upload_file\"> <input type=\"submit\" value=\"Carica\">\n" ."<input type=\"hidden\" name=\"action\" value=\"upload\">\n" ."</form>\n"; break; } ftp_quit($connection); ?> Said that this script works, $upload_file_name is an undeclared var and after the execution of this script if I echo it, it prints on creen the name of file. Furthermore, if I declare this var with a different name, just to try renaming the file, I get an error in the upload procedure which tells me it cannot open the file from my hard drive.

« previous php.notes (#76885) next »