Are you using enctype=multipart/form-data?
Is it possible to upload a file with other data on the same request ?
I try to upload a file with other fields like name, birth date , ....
the problem is : using Axios I have to use new FormData() and the problem of FormData is it sends data as a string. event with JSON.stringify()
If the sent value is different than String or Blob it will be automatically converted to String
source : https://developer.mozilla.org/en-US/docs/Web/API/FormData/append
My question : How to send a form data (including file) using Axios ?
But that's not how you build up a FormData object from scratch; the test field should be a Blob in that case:
form.append('companyData', new Blob([JSON.stringify(this.companyData)]), 'data.json')
This sends the JSON content as a file (another file in addition to the image) whose field name is companyData. You can get the file contents on the server side using :
$file = request()->file('companyData');
$json = json_decode($file->getContent(), true);
dump($json);
Please or to participate in this conversation.