我有多个文件上传字段。在开始时,当用户单击添加按钮时没有字段,它会显示文件上传字段
在视图中
PHP
<?php echo $i = 0;?>
Javascript
var i = '<?php echo $i?>';
<input type="file" name="product_image_' + i +'"/>
当我提交表单时显示此输出
Array
(
[product_image_1_] => Array
(
[name] => 25412_D80_backsanspic.png
[type] => image/png
[tmp_name] => C:\xampp\tmp\php68.tmp
[error] => 0
[size] => 355623
)
[product_image_2_] => Array
(
[name] => 25420_D40_right.png
[type] => image/png
[tmp_name] => C:\xampp\tmp\php69.tmp
[error] => 0
[size] => 347694
)
[product_image_3_] => Array
(
[name] => 26135_P6000_34r.png
[type] => image/png
[tmp_name] => C:\xampp\tmp\php6A.tmp
[error] => 0
[size] => 420441
)
[product_image_4_] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
)
您可以看到每个文件上传字段中都有下划线。我不明白这怎么可能。另外,如果我这样做
echo $_FILES['product_image_4_']['error'];
它显示输出,但这不
echo $_FILES['product_image_4']['error'];
相反,它会产生错误 undefined index product_image_4 任何建议。我正在使用基于 codeigniter 的 pyrocms。