检查文件扩展名 [英] Check the file extension

查看:89
本文介绍了检查文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想检查上传文件的扩展名。


我使用file属性上传bmp图像。现在我要将文件上传文本编辑为bmp文件到gif ...


示例:我上传c:/sample.bmp现在我手动编辑文件输入框为c :/sample.gif我上传了这个。


现在我想查看orignial文件ext ..在javascript或php中有什么办法.....

Hi,

I want to check the extension of uploaded file.

I upload the bmp image using file property. Now i am going to edit the file upload text as bmp file into gif...

example : i upload c:/sample.bmp now i manually edit the file input box as c:/sample.gif and i upload this one.

Now i want to check the orignial file ext.. is there any way in javascript or php.....

推荐答案

你好。


你是什么意思:手动编辑文件输入框?

你在做什么后对这些文件做什么上传它们?


您需要更好地解释这一点。
Hi.

What do you mean by: "manually edit the file input box"?
What are you doing with the files after you upload them?

You need to explain this a lot better.


Heya,maheswaran。


尝试验证文件本身的mime类型,而不是验证扩展名。 Fileinfo扩展程序非常适用于此( http://php.net/finfo_file )。
Heya, maheswaran.

Instead of validating the extension, try validating the mime-type of the file itself. The Fileinfo extension works very well for this (http://php.net/finfo_file).


hi


使用以下内容作为if条件

hi

use the following for your if condition


这篇关于检查文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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