[Vuejs]-Laravel Image Validation

-2👍

check this format

  'imageFile' => 'required|file|max:512|mimes:jpg,png,jpeg'

-2👍

You can Try This

'image' => 'required|file|image|max:2048'

-2👍

I used the FormData in order to get this work. It was fairly simple after that with a basic axios post request. I will add the finalized code I used. This JavaScript code was able to send an image properly to the backend which was validated in Laravel as an image.

let formData = new FormData();
Object.keys(this.form).forEach(key => {
 formData.append(key, this.form[key]);
});
formData.append('imageFile', this.imageFile);

axios({
  method: 'POST',
  url: this.routes.save,
  data: formData
})

Leave a comment