if (!(file_exists(http://mysite.com/images/thumbnail_1286954822.jpg))) {
$filefound = '0';
}
왜 작동하지 않습니까?파일이 PHP에 존재하는지 확인하십시오.
if (!(file_exists(http://mysite.com/images/thumbnail_1286954822.jpg))) {
$filefound = '0';
}
왜 작동하지 않습니까?파일이 PHP에 존재하는지 확인하십시오.
if (!file_exists('http://mysite.com/images/thumbnail_1286954822.jpg')) {
$filefound = '0';
}
if (! file_exists ($ base_url.'images/thumbnail_1286954822.jpg ')) { $ filefound ='0 '; } 실제로 죄송합니다. – anonymous
@anonymous 실제로는 미안합니다. $ base_url + images/thumbnail_1286954822.jpg를 요청하지 않았습니다. http : // mysite com/images/thumbnail_1286954822.jpg –
이 함수는 문자열을 기대하고있다.
file_exists()
은 HTTP URL에서 제대로 작동하지 않습니다.
해임에게 보내는 귀하의 의견에 따르면,이 내용은 귀하의 서버에있는 파일입니까? 그렇다면 URL이 아닌 파일 시스템 경로를 사용해야합니다 (예 : file_exists('/path/to/images/thumbnail.jpg')
).
file_exists은 지정된 경로에 파일이 있는지 여부를 확인합니다.
구문 :
file_exists (string $filename)
반환 TRUE
파일 이름에 지정된 파일이나 디렉토리가 존재하는 경우; 그렇지 않으면 FALSE
입니다.
$filename = BASE_DIR."images/a/test.jpg";
if (file_exists($filename)){
echo "File exist.";
}else{
echo "File does not exist.";
}
또 다른 방법은 getimagesize()를 사용할 수 있습니다, 그것은 파일/디렉토리가 지정된 경로에서 사용할 수 없습니다 0 (영) 경우 반환합니다.
if (@getimagesize($filename)) {...}
+1은 @getimagesize이고, 우리는 리소스 디렉토리 + 파일 이름 (그리고 파일 이름이 비어있는 경우)을 전달해야합니다. '@getimagesize (IMGDIR. "/ $ imgname")' –
예, 설명을 추가해 주셔서 감사합니다. – IRSHAD
http://stackoverflow.com/questions/981954/how-can-one-check-to-see-if-a-remote-file-exists-using-php [PHP의 – ArK
가능한 중복 : 이미지 파일이 있는지 확인하는 방법?] (http://stackoverflow.com/questions/7991425/php-how-to-check-if-image-file-exists) –