【发布时间】:2018-08-14 04:58:56
【问题描述】:
我有一个 HTML 表单并试图在 PHP 中对其进行解析,但图像输入似乎都没有按预期工作
我的 HTML 如下:
<form action="admin_catalog.php" name="new_product_form" id="new_product_form" method="post" enctype="multipart/form-data">
<table class="table">
<tr><td>Product Name:</td><td><input type="text" id="product_name" name="product_name"></td></tr>
<tr><td>Sort Order:</td><td><input type="number" id="product_sort" name="product_sort" value="1"></td></tr>
<tr><td>Category:</td><td><select name="product_category" id="product_category"><?php echo $category_options; ?></select></td></tr>
<tr><td>Product Attributes:</td><td><select name="product_attribute" id="product_attribute"><?php echo $attribute_options; ?></select></td></tr>
<tr><td colspan="2"><hr></td></tr>
<tr><td>Product Images:</td>
<td>
<input type="file" id="product_image_1" name="product_image_1">
<input type="file" id="product_image_2" name="product_image_2">
<input type="file" id="product_image_3" name="product_image_3">
<input type="file" id="product_image_4" name="product_image_4">
<input type="file" id="product_image_5" name="product_image_5">
</td>
</tr>
<tr><td colspan="2"><hr></td></tr>
<tr><td>Product Description:</td><td><textarea id="product_description" name="product_description" style="width:170px;height:100px;"></textarea></td></tr>
<tr><td colspan="2"><hr></td></tr>
<tr><td>Supplier:</td><td><input type="text" id="product_supplier" name="product_supplier"></td></tr>
<tr><td>Suppliers Model No:</td><td><input type="text" id="product_model_no" name="product_model_no"></td></tr>
<tr><td>Suppliers Cost:</td><td><input type="text" id="product_cost" name="product_cost"></td></tr>
</table>
<input type="submit" id="product_submit" name="product_submit" value="Add Product">
</form>
然后在我的 PHP 中我刚刚做了:
if (isset($_POST['product_name'])) {
var_dump($_POST);
}
但我得到的结果显示没有任何图像被发布:
array (size=9)
'product_name' => string 'tgjss' (length=5)
'product_sort' => string '1' (length=1)
'product_category' => string '1' (length=1)
'product_attribute' => string '2' (length=1)
'product_description' => string 'dfhksfhg' (length=8)
'product_supplier' => string 'ksgfhk' (length=6)
'product_model_no' => string 'sgfk' (length=4)
'product_cost' => string 'sfgk' (length=4)
'product_submit' => string 'Add Product' (length=11)
我已经仔细检查了所有内容,要么我错过了一些愚蠢的东西,要么我忘记了如何编码。对此的任何帮助将不胜感激
【问题讨论】:
标签: php html post file-upload