可以把上傳文件的文件名的擴展名進行判斷
如果為jpg bmp等就是圖片了!!

解决方案 »

  1.   

    记得php.net上的documents里,有人提供过一个通过HTTP判断一个图片文件是否存在的函数,但忘了在哪里。。我觉得应该原理值得用一下:)
      

  2.   

    找到啦,以下摘自php.net
    For file_exists command:I have found a quick fast non-fuss way to help you to check if an image file exists via HTTP:$image_info = @getimagesize("http://$filelocation/$filename");
    $type=$image_info[2];
      if ($type == 0) {
                    echo "file doesnt exists";
                    } else {
                    echo "the file exists";
                    }
      

  3.   

    扩展名也不算太多呀,列一个列表遍历比较一下就行了
    不过如果没有扩展名的话只好看文件的magic值了
    呵呵
      

  4.   

    <?
    $len=strlen($file_name);
    $aa=substr($file_name,$len-4,4);
    //取出的$aa就是扩展名了,至于如何if好办了
    ?>
      

  5.   

    一般的图片扩展名:BMP,JPG,GIF,JPEG。其他的网络上也少见了。