PHP's file_exists() will not work for me?

前端 未结 7 1756
既然无缘
既然无缘 2020-12-01 04:21

For some reason this PHP code below will not work, I can not figure it out.

It is very strange, file_exists does not seem to see that the image does exist, I have c

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 04:49

    file_exists() needs to use a file path on the hard drive, not a URL. So you should have something more like:

    $thumb_name = $_SERVER['DOCUMENT_ROOT'] . 'images/userphoto/1/2/2/59874a886a0356abc1_thumb9.jpg';
    if(file_exists($thumb_name)) {
        some_code
    }
    

    http://us2.php.net/file_exists

提交回复
热议问题