Sunday, 4 August 2019

Laravel: Form file uploads failing - incorrect type detected

I have recently gone live with a system that uploads CV's and I am getting an unusually high number of rejections, approximately 15%. When I look at the log it shows me the following results:

  • The extension reported by the client is docx (based on $file->getClientOriginalExtension())
  • The MIME type reported by the client is application/vnd.openxmlformats-officedocument.wordprocessingml.document (based on $file->getClientMimeType())
  • Laravel/PHP detects that the files are .bin (based on $file->extension())

In other words, the client says it is uploading a docx file, but the server says it receives a bin. At first I thought it was simply corruption, but it occurs far to often.

I have only captured a few in the logs so far, but I note that each time Safari has been the browser. Are there any systemic issues with Safari? If so, how do I get around them?

What else could cause the problem?

I am triggering the form submit with Vue, but I don't see how that could make a difference. Here is the Vue code:

document.getElementById("new-application").submit();



from Laravel: Form file uploads failing - incorrect type detected

No comments:

Post a Comment