I have an array:
This is the output of:
PHP Code:
print_r($_FILES);
Code:
Array
(
[pictures] => Array
(
[name] => Array
(
[0] => 001.jpg
[1] => 002.jpg
[2] => 003.jpg
[3] => 004.jpg
[4] => 005.jpg
)
[type] => Array
(
[0] => image/jpeg
[1] => image/jpeg
[2] => image/jpeg
[3] => image/jpeg
[4] => image/jpeg
)
[tmp_name] => Array
(
[0] => /tmp/phpMX74IR
[1] => /tmp/phpkKSkL9
[2] => /tmp/php041QAv
[3] => /tmp/php8abbHU
[4] => /tmp/phpDfIzDn
)
[error] => Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
[4] => 0
)
[size] => Array
(
[0] => 46433
[1] => 412167
[2] => 356231
[3] => 417250
[4] => 151399
)
)
)
Input fields look like this:
Code:
<input type="file" name="pictures[]" />
<input type="file" name="pictures[]" />
<input type="file" name="pictures[]" />
<input type="file" name="pictures[]" />
I'm trying to grab the attributes of each file and insert them into their respective columns in mysql but I can't figure out how to do that exactly. I've been searching just about everywhere! I mostly work with 1 dimensional arrays and this has got me stumped...
A single row would consist of:
['pictures']['name']['0'], ['pictures']['type']['0'], ['pictures']['tmp_name']['0'], ['pictures']['error']['0'], ['pictures']['size']['0']
0 is the first file
This needs to increment for each subsequent row:
['pictures']['name']['1'], ['pictures']['type']['1'], ['pictures']['tmp_name']['1'], ['pictures']['error']['1'], ['pictures']['size']['1']
1 is the second file, etc.
Sometimes only one file will be uploaded, sometimes a lot of files could be uploaded, my intentions are to not limit the number of files being uploaded.
Any guidance is much appreciated, thanks!