php image upload problem in IE

2.9k views Asked by At

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

2

There are 2 answers

1
karim79 On BEST ANSWER

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.

1
RaviM On

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