通过 php 上传时.flv 文件没有类型
谁能解释一下:
Array
(
[video] => Array
(
[name] => 20051210-w50s.flv
[type] =>
[tmp_name] => /tmp/php38JFea
[error] => 0
[size] => 669036
)
)
我正在上传 flv 文件,但 [type] 未填写,这常见吗?
提前欢呼!
can anyone shed some light on this:
Array
(
[video] => Array
(
[name] => 20051210-w50s.flv
[type] =>
[tmp_name] => /tmp/php38JFea
[error] => 0
[size] => 669036
)
)
I'm uploading an flv file, but the [type] is not being filled, is this common?
cheers in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
type
字段是客户端设置的MIME类型。在这种情况下,它只是不知道 flv 文件是什么,并且没有设置它。最好不要依赖此信息,因为攻击者可以随意更改它。如果您想获得有关上传视频文件的可靠信息,您需要进行服务器端检查。例如 getid3 似乎能够识别 flv 文件。
内置的
getimagesize()
函数可以做到对于许多图像格式来说也是如此。The
type
field is a MIME type set by the client. In this case, it just didn't know what a flv file is, and didn't set it. It is a good thing not to rely on this information, as it can be freely altered by an attacker.If you want to get reliable info about an uploaded video file, you need to do a server-side check. The getid3 for example seems to be able to recognize flv files.
The built-in
getimagesize()
function can do the same for many image formats.