Laravel:表单文件上传失败-检测到错误的类型 [英] Laravel: Form file uploads failing - incorrect type detected

查看:376
本文介绍了Laravel:表单文件上传失败-检测到错误的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近启用了上传简历的系统,但拒绝率却异常高,大约为15%.当我查看日志时,它显示了以下结果:

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:

  • 客户端报告的扩展名为docx(基于$file->getClientOriginalExtension())
  • 客户端报告的MIME类型为application/vnd.openxmlformats-officedocument.wordprocessingml.document(基于$file->getClientMimeType())
  • Laravel/PHP检测到文件为.bin(基于$file->extension())
  • 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())

换句话说,客户端说它正在上传docx文件,但是服务器说它接收到一个bin.起初我以为只是腐败,但它经常发生.

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.

到目前为止,我仅在日志中捕获了一些日志,但是我注意到每次Safari都是浏览器时. Safari是否存在系统性问题?如果是这样,我该如何解决?

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?

我正在使用Vue触发表单提交,但是我看不出这有什么用.这是Vue代码:

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();

推荐答案

问题是PHP使用OS(在本例中为Ubuntu)中的file命令来根据文件内容猜测扩展名.弄错了.升级Ubuntu可能会有所帮助.

The problem was that PHP uses the file command from the OS (in this case Ubuntu) to guess the extension based on the contents of the file. It was getting it wrong. Upgrading Ubuntu would probably help.

这篇关于Laravel:表单文件上传失败-检测到错误的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆