<form action = "index.php" method = "POST" enctype = "multipart/form-data">
<input type = "file" name = "image_name" /><input type = "submit" value = "Upload" name = "upload"/>
</form>
<?php
include("connect.php");
if(isset($_POST['upload'])){
$file = file_get_contents($_FILES['image_name']['tmp_name']);
$name = $_FILES['image_name']['name'];
$image_size = getimagesize($_FILES['image_name']['tmp_name']);
if($image_size == false){
echo "Thats not an image.";
}
}
?>
出现错误。如何避免错误通知?
以下是错误消息:
注意:getimagesize()[function.getimagesize]:读取错误!在第16行的C:\ xampp \ htdocs \ picture \ index.php
答案 0 :(得分:3)
使用@getimagesize
来取消通知。如果文件无法作为图像读取,则错误是预期的行为。
有关@
运算符的详细信息,请参阅PHP: Error Control Operators。