我刚测试了这个简单的php文件上传脚本。适用于IE以外的所有浏览器:(
IE在代码中定义“FILETYPE NOT SUPPORTED”:
if (isset($_POST['add'])) {
$order = $_POST['display_order'];
$img = $HTTP_POST_FILES['imagefile']['name'];
$url = $_POST['url'];
// CONNECT TO DB
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$types = array('image/jpeg', 'image/gif', 'image/png', 'image/tiff', 'image/bmp', 'image/pjpeg');
$target_path = "media/";
$target_path = $target_path . basename( $_FILES['imagefile']['name']);
if (in_array($_FILES['imagefile']['type'], $types)) {
if(move_uploaded_file($_FILES['imagefile']['tmp_name'], $target_path)) {
mysql_query(
"INSERT INTO slider_luxury
(display_order, imagefile, url)
VALUES
('$order', '$img', '$url')"
);
header('Location: luxury_slider.php');
} else {
echo "There was an error uploading the slide, please try again!";
}
} else {
echo "FILETYPE NOT SUPPORTED";
}
}
答案 0 :(得分:1)
这意味着IE使用另一种MIME类型发送png而不是“image / png”,这正是您所期望的。尝试添加到您接受的值数组中:
image/x-png
另见What is the difference between "image/png" and "image/x-png"?。