开发者

File type is returning null in chrome browser

开发者 https://www.devze.com 2023-01-27 18:21 出处:网络
I have used file uploader(used PHP) in my application. In FireFox, and Internet Explorer8 working when I try below statement.

I have used file uploader(used PHP) in my application.

In FireFox, and Internet Explorer8 working when I try below statement.

开发者_开发问答
print $_FILES['upladed']['type'];

But in chrome I am getting null value(not printing anything).

If I use var_dump($_FILES['upladed']['type']); then I am getting result as

string '' (length=0)

Please suggest some pointers.

Thanks

-Pravin


First of all, use var_dump($_FILES['upladed']['type']) to figure out if it's really NULL or not.

Second of all, I don't know what's wrong with Chrome, but you should not rely on this value in your PHP application. Always validate the data over the wire than checking what MIME type the browser really claims to be. In Windows, MIME types can be changed in registry, for instance.


Chrome (up to at least 8.0.552.215) has issues with content types of files. For me, it was if the file did not have an extension.

See: http://code.google.com/p/chromium/issues/detail?id=6800

Note: I'm using struts 2.0.14 with the FileUploadInterceptor (uses ServletFileUpload and JakataMultipartRequest)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号