【问题标题】:php image type, mozila and IE7php 图片类型,mozila 和 IE7
【发布时间】:2010-11-30 20:03:41
【问题描述】:

我在页面中插入图像,奇怪的是我得到了类型的图片。

显示类型:$_FILES['img']['type']。

结果:

Firefox: image/jpeg
IE7: 'image/pjpeg'

Firefox: image/png
IE7: image/x-png

现在我使用这个过滤器:

$type_filter = array('image/gif', 'image/jpeg', 'image/png', 'image/jpg', 'image/bmp', 'image/x-png', 'image/pjpeg');

很好,还是缺少其他东西? 谢谢

【问题讨论】:

  • 我认为您正在上传文件,因此您使用的是 $_FILES。使用 $_FILES['img']['type'] 会给你 PHP 所说的,而不是你的数组所说的。

标签: php


【解决方案1】:

我通常会这样做:

if(stristr($_FILES['image']['type'], "image")){
enter code here
}

【讨论】:

  • 很好,谢谢 ;) 但我希望只允许:png、jpg、gif 和 bmp 图像类型
猜你喜欢
  • 2014-09-04
  • 1970-01-01
  • 2017-06-30
  • 1970-01-01
  • 1970-01-01
  • 2012-07-13
  • 2012-06-16
  • 2011-06-04
  • 1970-01-01
相关资源
最近更新 更多