I have a form that accepts user input and asks them to upload a file (image, but that doesn't matter for this question). When the user presses submit the field for the file doesn't seem to get passed to the action script.
The form is defined as this:
<form name="AddProduct" id="AddProduct" method="post" enctype="multipart/form-data" action="dothing.php">
<tr>
<td >Item UPC</td>
<td><input name="upccode" type="text" id="upccode" size="40" value="" maxlength="255"></td>
</tr>
<tr>
<td>Item Description</td>
<td><input name="proddesc" type="text" id="proddesc" size="40" value="" maxlength="255"></td>
</tr>
<tr>
<td>Item Image</td>
<td><input type="file" name="file" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Add !" class="submit">&l开发者_StackOverflow中文版t;/form></td>
</tr>
On dothing.php if I do a print_r($_POST);
this is what I get
Array ( [upccode] => 159874288 [proddesc] => A fancy widget [submit] => Add ! )
If I look at the request as it is being posted I have this:
-----------------------------11192760525264\r\nContent-Disposition: form-data; name="upccode"\r\n\r\n159874288\r\n-----------------------------11192760525264\r\nContent-Disposition: form-data; name="proddesc"\r\n\r\nA fancy widget\r\n-----------------------------11192760525264\r\nContent-Disposition: form-data; name="file"; filename="gif.gif"\r\nContent-Type: image/gif\r\n\r\nGIF87a?à÷
Where is my file
variable on the dothing.php page? It clearly shows it being passed.
@Andy: The file
won't be in the $_POST
collection, it will be in $_FILES
.
精彩评论