IE下php图片上传问题

发布于 2024-10-15 20:30:39 字数 1121 浏览 8 评论 0 原文

我得到了这个 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

请帮助我,因为我不知道如何解决该问题,

谢谢

I got this php uploading script which is working fine on 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;
    }
}
}

My problem occurs only in IE and when try to upload an image I got the
error no 4 - UPLOAD_ERR_NO_FILE

Please help me as I have no clue what to do to solve the problem

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

枉心 2024-10-22 20:30:39

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.

一笔一画续写前缘 2024-10-22 20:30:39

如果您可以指出行号突出显示出现此错误的行

,或者您可以参考这个简单的示例,它可以正常工作: 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文