exif_imagetype错误,filename不能为空

时间:2013-10-19 14:38:59

标签: php sql validation

下面是我的代码,用于检查上传的图像是否是特定于.png文件的图像。但是我收到一个错误,说exif_imagetype:filename不能为空。

//finally move the file to permanent location
        if(exif_imagetype($_FILES[$thumbnail_fieldname]['tmp_name'] == IMAGETYPE_PNG)){ 
            if(move_uploaded_file($_FILES[$thumbnail_fieldname]['tmp_name'], $thumbnail_filename)){
                //DATETIME
                $date = date("Y-m-d H:i:s");

                //insert into SQL code here
                $insert_sql = "INSERT INTO walls(wall_name, thumbnail_path, upload_date) " .
                              "VALUES ('{$wall_name}', '{$thumbnail_filename}', '{$date}');";

                echo "<p>Success: Image/s uploaded.</p>";
            }else{
                echo "<p>Error: Image/s not uploaded.</p>";
                }
        }else{
            echo "<p>Error: This is not an image.</p>";
        }

1 个答案:

答案 0 :(得分:1)

注意你的括号。该行应为

if(exif_imagetype($_FILES[$thumbnail_fieldname]['tmp_name']) == IMAGETYPE_PNG)