note 54827 added to function.ftp-put
| From: | Icy_Tiger_2000 at yahoo dot com dot au | Date: | Sat, 16 Jul 2005 08:35:36 +0000 |
| Subject: | note 54827 added to function.ftp-put | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92053@lists.php.net to get a copy of this message | ||
I had a little trouble getting the ftp_put to work, because of that particular server. All
variables and data parsed from the previous web form had to be retreived using $_POST, $_GET or
$_FILES.
If you don't know what you sent use phpinfo(); to display what the server thinks about your
data.
so...when sending files using a form and PHP, make sure that all the data (text files etc...) are
retreived with $_POST, and files (smiley.png, compression.zip, etc...) are retreived with $_FILES.
here's what your start of a results.php file might look like:
<?PHP
$myName = $_POST['name']; //This will copy the text into a variable
$myFile = $_FILES['file_name']; // This will make an array out of the file information
that was stored.
?>
Now when it comes to transmitting that information...
<?PHP
$destination_path = "src/bin/";
//where you want to throw the file on the webserver (relative to your login dir)
$destination_file = $destination_path."img.jpg";
//This will create a full path with the file on the end for you to use, I like splitting the
variables like this in case I need to use on on their own or if I'm dynamically creating new
folders.
$file = $myFile['tmp_name'];
//Converts the array into a new string containing the path name on the server where your file is.
$upload = ftp_put($conn_id, $destination_file, $file, FTP_BINARY);// upload the file
if (!$upload) {// check upload status
echo "FTP upload of $destination_file has failed!";
} else {
echo "Uploaded $file to $conn_id as $destination_file";
}
?>
hope this is usefull ^_^
----
Manual Page -- http://www.php.net/manual/en/function.ftp-put.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54827
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54827&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54827&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54827&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54827&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54827&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54827&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54827&report=yes
Search -- http://master.php.net/manage/user-notes.php