Jump to content

$_POST["file"] not working


telliott99

Recommended Posts

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?

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.