开发者

PHP Error only present in Internet Explorer

Okay this has baffled me. My script works in Mozilla but not IE. I get this error in IE:

Warning: move_uploaded_file(uploads/properties/yh96gapdna8amyhhmgcniskcvk9p0u37/) [function.move-uploaded-file]: failed to open stream: Is a directory in /homepages/19/d375499187/htdocs/sitename/include/session.php on line 602

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpJkiaF3' to 'uploads/properties/yh96gapdna8amyhhmgcniskcvk9p0u37/' in /homepages/19/d375499187/htdocs/sitename/include/session.php on line 602

my code at Session.php is:

function addPhoto($subphotoSize,$subphotoType,$subphotoTmpname,$subphotoDesc,$subfieldID,$subsessionid){
    global $database, $form;

    /* Get random string for directory name */
    $randNum = $this->开发者_Go百科;generateRandStr(10);

    $maxFileSize = 2500000; // bytes (2 MB)
    $filerootpath = PHOTOS_DIR.$subsessionid."/";
    if($subphotoType == "image/png"){
        $filename = $randNum.".png";
    } else if ($subphotoType == "image/jpeg"){
        $filename = $randNum.".jpg";
    }
    $fullURL = $filerootpath.$filename;

    /* Image error checking */
    $field = "photo";
    if(!$subphotoTmpname){
        $form->setError($field, "* No file selected");
    } else {
        if($subphotoSize > $maxFileSize) {
            $form->setError($field, "* Your photo is above the maximum of ".$maxFileSize."Kb");
        } else if (!is_dir($filerootpath)){
            mkdir($filerootpath,0777);
            chmod($filerootpath,0777);
        }
        move_uploaded_file($subphotoTmpname, "$fullURL");
    }
    /* Errors exist, have user correct them */
    if($form->num_errors > 0){
        return 1;  //Errors with form
    } else {
        if($subfieldID == "1"){ // If the first field...
            $is_main_photo = 1;
        } else {
            $is_main_photo = 0;
        }
        if(!$database->addNewPhoto($ownerID,$subphotoDesc,$fullURL,$userSession,$is_main_photo, $subsessionid)){
            return 2; // Failed to add to database
        }
    }
    return 0; // Success
}

It creates the folder no problem but doesnt do anything else.


Add a log message to see what's the value of $subphotoType. My guess is that when you upload the file from Internet Explorer it's neither image/png nor image/jpeg, in which case $filename will be empty because you don't have an else clause.

if($subphotoType == "image/png"){
    $filename = $randNum.".png";
} else if ($subphotoType == "image/jpeg"){
    $filename = $randNum.".jpg";
} else {
    // No else! $filename will be empty.
}

If you tune your error reporting settings properly you should see a notice saying you are trying to use an undefined variable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜