I wrote a code in Lumen to upload multiple images at once using cloudinary, but the code doesn't work only the first image gets uploaded.
$images = $request->file('picture');
$uploaded = [];
foreach ($images as $image) {
error_log('for statement fires.');
Cloudder::upload($image, null, [
'folder' => '/dog-lovers',
'discard_original_filename' => true,
]);
$image_uploaded = Cloudder::getResult();
array_push($uploaded, $image_uploaded['url']);
}
return array('message'=>'successful', 'file_url'=>$uploaded);
In the above code, the for statement doesn't get called, because $images isn't an array i guess, so I made $images an array
$images[] = $request->file('picture');
Now the for statement fires up, but only the first selected image from postman gets uploaded
this is a screenshot from my postman just in case anyone is wondering how i'm uploading via postman
Does anyone have any idea why the other 4 images don't get uploaded and how to fix this?
This solution to this is to make the picture parameter on postman an array, like this picture[]
decided to post the solution incase anyone ran into similar problems