thanks for the help, $_FILES is giving the file name. but ftp_put is not working. login works and I am connected to the ftp server. command is
$upload = ftp_put($conn_id, $remote_file, $file, FTP_ASCII);
uploading a csv file,
tried both ASCII and BINARY ,
tried Passive mode,
verified that hosting company allows ftp uploads
tried providing path name to public-ftp
only error message is my own php error message, doesnt say why. any ideas? code below.
$file = $_FILES["file"]["name"];
$directory = $_POST["directory"];
echo "directory = ",$directory,"<br>";
include($directory."phud.php");
echo "Uploaded file = ",$file,"<br>";
echo "Save As file = ",$remote_file,"<br>";
print_r($_FILES['file']);
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name....";
exit;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name","<br>";
}
// turn passive mode on
ftp_pasv($conn_id, true);
// upload the file
$upload = ftp_put($conn_id, $remote_file, $file, FTP_ASCII);
// check upload status
if (!$upload) {
echo "FTP upload has failed!","<br>";
} else {
echo "Uploaded $name to $ftp_server ","<br>";
}
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
echo "Successfully uploaded $file\n";}
else {echo "There was a problem while uploading $file\n";}
// close the FTP stream
ftp_close($conn_id);