I am having multiple fields of file upload. In the start there is no field when a user clicks on add button it displays a file upload field
In View
PHP
<?php echo $i = 0;?>
Javascript
var i = '<?php echo $i?>';
<input type="file" name="product_image_' + i +'"/>
When i submit the form if displays this output
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
)
)
You can see there is underscore in each file upload field. I dont understand how this is possible. Also if i do this
echo $_FILES['product_image_4_']['error'];
It displays output but this does not
echo $_FILES['product_image_4']['error'];
Instead it produces error undefined index product_image_4 Any suggestion. I am using pyrocms built on codeigniter.