解决方案 »

  1.   

    file_exists 就只能检查本地文件,远程用get_headers获取头信息来判断,你这个需求在<img标签加个onerror也能解决。
      

  2.   

    var_dump(file_exists('http://saberlily-images.stor.sinaapp.com/load.jpg'));
    打印出来为false;
    话说file_exists貌似只能用来判断webroot下面的。
      

  3.   

    $id = isset($_POST['id'])? $_POST['id'] : 0;
    $filename = 'http://saberlily-images.stor.sinaapp.com/load.jpg';
    if(getimagesize($filename)){
    echo '11<img src="'.$filename.'" width="auto" height="auto">';
    }else{
    echo '<img src="http://saberlily-images.stor.sinaapp.com/load.jpg" width="auto" height="auto">';
    }
    '<img src=".$filename." width="auto" height="auto">';
    外面是单引号,$filename是不能解析的
      

  4.   

    file_exists只适用于本机或者网络共享文件夹的文件。
      

  5.   

    file_exists只能判斷本地的,判斷http的不行。
    <?php
    $filename = '/path/to/foo.txt';if (file_exists($filename)) {
        echo "The file $filename exists";
    } else {
        echo "The file $filename does not exist";
    }
    ?>
    http://cn2.php.net/file_exists要判斷遠程文件是否存在可以這樣寫function check_remote_file($url){
    $result = get_headers($url, 1);
    if($result[0]=='HTTP/1.1 200 OK'){
    return true;
    }else{
    return false;
    }
    }$id = isset($_POST['id'])? $_POST['id'] : 0;
    $filename = 'http://saberlily-images.stor.sinaapp.com/' .strval($id). '.jpg';
    if(check_remote_file($filename)){
        echo '<img src=".$filename." width="auto" height="auto">';
    }else{
       echo '<img src="http://saberlily-images.stor.sinaapp.com/load.jpg" width="auto" height="auto">';
    }
      

  6.   

    现在我在Dream Weaver能完美运行了,可是上传到SAE服务器上就不显示了。是什么情况