I want to upload multiple files with a form.
So at the post I have this code that does not work.Why?
if (count($_FILES['presoFile']) > 0) {
FOREACH ($_FILES['presoFile'] as $name) {
if ($name['error'] == 0) {
$uploadtrumpdir = './files/images/imgs/';
$uploadtrumpfilename = rand(100000000, 199999999) . "_" . basename($name['presoFile']['name']);
move_uploaded_file( $name["tmp_name"], $uploadtrumpfile);
..............................
}
}
}
What does that mean? Do you get an error?
The files do not upload,I notice that I can not read the $name[“tmp_name”],it is blank.
Do a var_dump of $_FILES and see what it contains.
So at the loop how can I get the “error” etc of the files?
FOREACH ($_FILES[‘presoFile’] as $index ) {
// echo($index[‘name’]); //move_uploaded_file($index[$index][“tmp_name”], $uploadtrumpfile);
var_dump($index);
}
array
2 => string ‘poter2.jpg’ (length=10)
3 => string ‘b167113.jpg’ (length=11)
array
2 => string ‘image/jpeg’ (length=10)
3 => string ‘image/jpeg’ (length=10)
array
2 => string ‘C:\xampp\ mp\php6C46.tmp’ (length=24)
3 => string ‘C:\xampp\ mp\php6CA4.tmp’ (length=24)
array
2 => int 0
3 => int 0
array
2 => int 439439
3 => int 27730