telliott99 Posted June 15, 2011 Share Posted June 15, 2011 Hi, I have used $_POST with type="text" and for type=" hidden". I am now using an html form with input type="file" but I do not get any file name data from the $_POST. html form has <form name="form" enctype="multipart/form-data" action="sp_ftpupload.php" method="POST" > <input type = "file" name = "file" size = "84" accept="text/csv" > <input type = "submit" value = "Upload" style = "vertical-align:middle" > </form> php code has $file = $_POST["file"]; echo "Uploaded file = ",$file,"<br>"; nothing is echo'd. What am I missing? Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted June 15, 2011 Share Posted June 15, 2011 file data is in the $_FILES super global. not $_POST Quote Link to comment Share on other sites More sharing options...
redixx Posted June 15, 2011 Share Posted June 15, 2011 You can print_r($_FILES['file']); to see all the information associated with it. Quote Link to comment Share on other sites More sharing options...
telliott99 Posted June 15, 2011 Author Share Posted June 15, 2011 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); Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted June 15, 2011 Share Posted June 15, 2011 What are you trying to do? Also, when posting code, please put your code between tags. Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.