Answer the question
In order to leave comments, you need to log in
Why aren't files uploaded to and the server returns an empty object?
There is a front on which I am trying to do image uploads, such as image hosting, nothing complicated, on the upload button the code is:
const handleUploadPhoto = async e => {
e.preventDefault();
const formData = new FormData();
fileList.forEach(file => {
formData.append("files", file, file.name);
});
const { data } = await axios.post("/api/upload", formData, {
headers: {
"Content-Type": "multipart/form-data"
}
});
console.log(data);
};
public function upload(Request $request)
{
return response()->json($request);
}
Answer the question
In order to leave comments, you need to log in
Sending a file to the back, I tried to see it, I don’t know why it doesn’t debug, at least it didn’t work for me, I added the back of saving images and everything works.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question