0

下面是我检查上传的图像是否是图像,特别是 .png 文件的代码。但是我收到一个错误,说 exif_imagetype: filename cannot be empty。

//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>";
        }
4

1 回答 1

1

注意你的括号。该行应为

if(exif_imagetype($_FILES[$thumbnail_fieldname]['tmp_name']) == IMAGETYPE_PNG)
于 2013-10-19T20:19:21.160 回答