奇怪的CodeIgniter文件上传错误
我已经设置了“Uploadify”来将文件上传到我的服务器,我在服务器上使用 CodeIgniter 的文件上传库处理它们。
但是,我认为 Uploadify 更改了文件的 mime 类型,或者做了其他奇怪的事情,导致 CodeIgniter 尽管允许,但仍给出“不允许的文件类型”错误。
例如,我允许使用 JPEG 文件,但是当我使用 Uploadify 上传它们时,我收到该错误。
有什么解决方法吗?基本上,我只想允许上传图像,例如.jpg、.jpeg、.bmp、.png。我是否必须手动检查文件的扩展名或者是否有更好的选择?
I've set up 'Uploadify' to upload files to my server where I process them with CodeIgniter's file upload library.
However, I think Uploadify changes the mime type of the files, or does something else weird which causes CodeIgniter to give a 'the file type is not allowed' error despite it being allowed.
E.g I've allowed JPEG files but when I upload them using Uploadify, I get that error.
Is there any workaround for this? Basically, I want only image uploads to be allowed, e.g .jpg, .jpeg, .bmp, .png. Do I have to manually check the extension of the files or is there any better option?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是对的,uploadify 对它上传的大多数(全部?)文件使用 mime 类型
application/octet-stream
。我认为这实际上是由 Flash 处理上传引起的,但我不能 100% 确定。在处理上传的控制器中,放入
print_r($_FILES)
并检查 mime 类型是什么,然后将其添加到您的application/config/mimes.php
文件。因此,在您的
mimes.php
文件中,您可能会包含以下内容:You're correct, uploadify uses the mime type
application/octet-stream
for most (all?) the files which it uploads. I think this is actually caused by Flash handling the uploading, but I'm not 100% sure.In your controller where you handle the upload, drop in a
print_r($_FILES)
and check out what the mime-type is, then just add it to yourapplication/config/mimes.php
file.So in your
mimes.php
file you'll probably have something like: