下面是我检查上传的图像是否是图像,特别是 .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>";
}