Voting

: max(four, three)?
(Example: nine)

The Note You're Voting On

Icy_Tiger_2000 at yahoo dot com dot au
19 years ago
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 ^_^

<< Back to user notes page

To Top