0

I have a form in my vue.js frontend where i upload multiple images and asynchronously send it to the backend. But it seems laravel cant understand it as a file because it's more than one.. And it works fine if it was just a single image without multiple attribute attached to the input field.By the way, i used form data to process the form.. Even tried to stringify the array of files and decode it in the backend still doesnt work.. It is processing it as a strings. When i loop through the files and try to use the function getClientOriginalName() (as i would with single upload) i get 'Call to undefined method stdClass::getClientOriginalName()'.. Also figured that the stdClass is an obj of numbers when i checked.. Below is my code.

  let product_img_array = this.image_data.map(item => item.file);
  let payload = new FormData;
  payload.append("all_images", JSON.stringify(product_img_array));

Backend:

foreach (json_decode(request()->all_images) as $key => $value) {
        dd($value->getClientOriginalName()); //this returns the error i mentioned above 
        dd($value);//this returns {#325} as i said earlier.
    }

What is it i'm doing wrongly, probably there is a way of doing this and i'm off track. Please your help is appreciated ..

Dipo Deen
  • 11
  • 3

0 Answers0