form submitted file but $_FILES[][] is empty

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chopficaro
Forum Commoner
Posts: 68
Joined: Fri Jan 01, 2010 12:56 am

form submitted file but $_FILES[][] is empty

Post by chopficaro »

i have a form that posts to a page where i try to echo
"\ntype ".$_FILES["file"]["type"].
"\nsize ".$_FILES["file"]["size"];
and it seems that this array is empty. here is the form:

Code: Select all

	echo "
<h1>add to ".$mysqlTableName."</h1>
 <form action=\"post.php\" method=\"post\">
  <label for=\"title\">Title</label>
  <input type=\"text\" name=\"title\" />
  <br />
  <label for=\"text\">Description</label>
  <input type=\"text\" name=\"text\" id=\"text\" />
  <br />
  <label for=\"price\">Price</label>
  <input type=\"text\" name=\"price\" id=\"price\" />
  <br />
  <label for=\"image\">Image</label>
	<input type=\"file\" name=\"image\" id=\"image\" /> 
	<br />

  <input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Submit\" />
 </form>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: form submitted file but $_FILES[][] is empty

Post by Celauran »

You forgot enctype="multipart/form-data" from your form tag.
Post Reply