I have an update ( patch form ) that can have some basic fields with one featured image and an array of gallery images.
updatePhotoPreview(event) {
this.featuredImagePreview = URL.createObjectURL(event.target.files[0])
this.updateProductForm.featured_image = event.target.files[0]
},
Before sending the request and even in the request header, the featured image is File and binary.
Then I'm simply posting the form with this.form.patch(url)
.
I'm getting an error the featured_image must be an image.
I've dumped the request and somehow my featured_image value has been set to an empty array.
The same is for the gallery images, it has been turned into an array of empty arrays.
I've tried changing the route to post, put, the result is the same, I've added a custom header
{ headers: {'Content-Type': 'multipart/form-data'} }
The result is the same.
but the same form is working for the create endpoint of this resource with POST method.
I've removed all the request classes and dumping with request()->all()
How can I fix this?
I fix this by adding '_method' on form and using 'post' request.