Reputation: 1225
If I upload the file array Image, I want to do something with each file. So I put Image[] in Postman and get it to function, But it occurs an error. I do something or select the files in first file in array,is it right $_FILES['Image'][0]? or different select?
If you know about it, Please help me
Update
for($i = 0 ; $i < $count ; $i++){
$file = $_FILES['Image']['name'][$i];
$ImagePath = $this->utils->sendFile($file);
}
I use this just copy it and paste and it occurs error message like this
Illegal tmp_name string
Upvotes: 0
Views: 722
Reputation: 1301
check this, i am sure it helps
$arr = $_FILES['image']['name'];
for($i = 0; $i < count($arr) ; $i++)
{
$file_name = $_FILES['image']['name'][$i];
$file_size = $_FILES['image']['size'][$i];
$file_tmp = $_FILES['image']['tmp_name'][$i];
$file_type = $_FILES['image']['type'][$i];
$responce = move_uploaded_file($file_tmp, "orders/".$file_name);
}
Upvotes: 0
Reputation: 1301
you can select file from postman by, image[0], image[1] and then you can take files array to controller by
$count = count($FILES['image']['name']);
for($i = 0 ; $i < $count ; $i++){
$file = $FILES['image']['name'][$i];
}
now you can pass this $file variable to move_uploaded_file() function oe in any other method. I hope it helps.
Upvotes: 0