IE下php图片上传问题
我得到了这个 php 上传脚本,它在 Mozilla、Chrome、Opera、Safari 上运行良好:
$image1=$_FILES['file1']['name'];
if ($image1)
{
$filename1 = stripslashes($_FILES['file1']['name']);
$extension1 = getExtension($filename1);
$extension1 = strtolower($extension1);
if (($extension1 != "jpg") && ($extension1 != "jpeg") && ($extension1 != "gif") && ($extension1 != "png"))
{
$errors=1;
}
else
{
$size1=filesize($_FILES['file1']['tmp_name']);
list($width1, $height1, $type1, $attr1) = getimagesize($_FILES['file1']['tmp_name']);
if($width1>=100 and $height1>100)
{
if ($size1 > MAX_SIZE*1024)
{
$errors=1;
}
else
{
$newname1="../wallImages/".$image1;
$copied1 = copy($_FILES['file1']['tmp_name'], $newname1);
if (!$copied1)
{
$errors=1;
}
}
}
else
{
$errors=1;
}
}
}
我的问题仅出现在 IE 中,当尝试上传图像时,我得到了
错误号 4 - UPLOAD_ERR_NO_FILE
请帮助我,因为我不知道如何解决该问题,
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IE 喜欢认为 jpeg 具有“image/pjpeg”mime 类型(而不是“image/jpeg”)。这可能就是原因。我建议发布您的
getExtension()
实现,或者确保 pjpeg 是您允许的扩展之一。IE likes to think that jpegs have the 'image/pjpeg' mime type (instead of 'image/jpeg'). That could be be the reason. I would suggest posting your implementation for
getExtension()
, or making sure that pjpeg is one of your allowed extensions.如果您可以指出行号突出显示出现此错误的行
,或者您可以参考这个简单的示例,它可以正常工作: http://www.w3schools.com/PHP/php_file_upload.asp
希望这会有所帮助。
谢谢
拉维·穆达利亚尔
Would help if you could point the line number highlight the line on which you get this error
or you can refer to this simple example it works fine : http://www.w3schools.com/PHP/php_file_upload.asp
hope this helps.
Thanks
Ravi Mudaliar