Forum Moderators: coopster
Code:
<?php
$myFile = $_FILES['file']; // This will make an array out of the file information that was stored.
$file = $myFile['tmp_name']; //Converts the array into a new string containing the path name on the server where your file is.
$myFileName = $_POST['MyFile']; //Retrieve file path and file name
$myfile_replace = str_replace('\\', '/', $myFileName); //convert path for use with unix
$myfile = basename($myfile_replace); //extract file name from path
$destination_file = "public_html/upload/".$myfile; //where you want to throw the file on the webserver (relative to your login dir)
// connection settings
$ftp_server = "IP"; //address of ftp server (leave out ftp://)
$ftp_user_name = "user"; // Username
$ftp_user_pass = "pass"; // Password
$conn_id = ftp_connect($ftp_server); // set up basic connection
// login with username and password, or give invalid user message
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass) or die("<h1>You do not have access to this ftp server!</h1>");
$upload = ftp_put($conn_id, $destination_file, $file, FTP_BINARY); // upload the file
if (!$upload) { // check upload status
echo "<h2>FTP upload of $myFileName has failed!</h2> <br />";
}
/*
// try to delete $file
if (ftp_delete($conn_id, $destination_file)) {
echo "$destination_file has been deleted!\n";
} else {
echo "Could not delete $destination_file!\n";
}
*/
ftp_close($conn_id); // close the FTP stream
?>
and the error:
Warning: ftp_put() [function.ftp-put]: Prohibited file name: public_html/upload/ in /home/user/public_html/upload/index.php on line 20
FTP upload of has failed!
Any help is much appreciated...