1
我有一個表單接受用戶輸入並要求他們上傳文件(圖像,但這對此問題無關緊要)。當用戶按下提交領域的文件似乎並沒有得到傳遞給操作腳本。PHP文件上傳 - 字段在操作頁面上不存在
形式的定義是這樣的:
<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"></form></td>
</tr>
在dothing.php如果我做一個print_r($_POST);
這就是我得到
Array ([upccode] => 159874288 [proddesc] => A fancy widget [submit] => Add !)
如果我看的要求,因爲它是被張貼我有這樣的:
-----------------------------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?à÷
哪裏是我的file
的dothing.php頁的變量?它清楚地表明它通過了。
是的,所有文件進入$ _FILES。 print_r($ _ FILES)會給你它的結構。不要忘記將其複製到永久位置,因爲它會上傳到臨時位置。 – Phoenix 2011-04-02 23:23:59