PHP错误仅出现在Internet Explorer中

PHP错误仅出现在Internet Explorer中,php,internet-explorer,Php,Internet Explorer,好吧,这让我很困惑。我的脚本可以在Mozilla中使用,但不能在IE中使用。我在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/incl

好吧,这让我很困惑。我的脚本可以在Mozilla中使用,但不能在IE中使用。我在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
我在Session.php中的代码是:

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

    /* Get random string for directory name */
    $randNum = $this->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
}

它创建文件夹没有问题,但不做任何其他事情

添加日志消息以查看$subphotoType的值。我的猜测是,当您从Internet Explorer上载文件时,它既不是image/png也不是image/jpeg,在这种情况下,$filename将为空,因为您没有else子句

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

如果您正确调整了错误报告设置,您应该会看到一个通知,说明您正在尝试使用未定义的变量。

您可以打印
$fullURL
并显示输出吗?您将向此函数传递什么?查看两种浏览器之间是否存在差异。例如,如果您正在从
$\u文件
传入文件名,请尝试类似
var\u dump($\u文件)的方法array(5){[“name”]=>string(8)“6122.jpg”[“type”]=>string(11)“image/pjpeg”[“tmp_name”]=>string(14)”/tmp/phpu8oMmx”[“error”]=>int(0)[“size”]=>int(493526)谢谢,我已经用它解决了这个错误,它是一个渐进式jpeg格式的mime类型。我现在有一个我在Mozilla中也没有得到的头错误。警告:无法修改头信息-头已经由发送(输出开始于/homepages/19/d375499187/htdocs/sitename/process.php:265)在271Im afriad第271行的/homepages/19/d375499187/htdocs/sitename/process.php中,这不起作用。我在表单中使用javascript来防止其他文件类型。无论如何,感谢您在客户端可能正在检查文件扩展名,而在服务器上检查文件内容类型,这是另一回事。检查并查看-添加一个else cla与die一起使用(“Got handled Content Type:$subphotoType”);您实际上是对的,但是else条件不起作用,因为无论那些if语句如何,我都在上传。谢谢