drqvsx1228 2013-06-21 02:30 采纳率: 0%
浏览 83

如何知道文件图片是否使用getimagesize功能

<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.";
}

}
?>

There is an error that appears. How can I avoid the error notice?

Here is the error message:

Notice: getimagesize() [function.getimagesize]: Read error! in C:\xampp\htdocs\picture\index.php on line 16

  • 写回答

1条回答 默认 最新

  • dongshijiao2363 2013-06-21 02:32
    关注

    Use @getimagesize to suppress the notice. An error is the expected behavior if the file can't be read as an image.

    See PHP: Error Control Operators for more information about the @ operator.

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line