$_POST["file"] not working

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

php code has

$file = $_POST[“file”];
echo “Uploaded file = “,$file,”
”;

nothing is echo’d. What am I missing?

Syntax here is always tricky. Are you sure you want “file” at input type?

thanks, yes I need input type=“file” but found out in another forum I need to use $_FILES instead of $_POST for that.

But now I find the uploaded file name does not have directory information and ftp_put cannot find the file. If I run the same script with a file in the web host directory it works fine but not when uploading a file from my computer. uploading files from an html form is pretty common, I hope someone has some advice on this. thanks

[php]

//get the original name of the file from the clients machine
	$filename = stripslashes($_FILES['image']['name']);
//get the extension of the file in a lower case format
	$extension = getExtension($filename);
	$extension = strtolower($extension);
   //we will give an unique name, for example the time in unix time format
	$image_name= $timestamp.'.'.$extension;

[/php]

This might help as I used this for an image upload if you need all of the code let me know

[php]echo “Uploaded file = “.$file.”
”; [/php]

Use full stops instead of commas ,
Remember to put error_reporting(E_ALL); in your pages. It will give you valuable information.

Suppose you have successfully uploaded the file, you can print its file name by:
[php]echo 'File uploaded: ’ . $_FILES[“file”][“name”];[/php]

For more info, visit http://t.co/PBHyi9U

Sponsor our Newsletter | Privacy Policy | Terms of Service