2012-07-18 81 views
0

我使用下面的代码,但它不适合我。file_exists不适用于我

$img1=$info['available_now']; //http://www.jjbsports.com/pws/client/images/catalogue/products/65014201/zoom/65014201_white.jpg 

$filename = $img1; 

if (file_exists($filename)) { 
     echo "The file $filename exists"; 
     echo '<img src="'; echo $id1; echo '"width="50" height="50"/>'."<br>"; 
} else { 
     echo "The file $filename does not exist"; 
     echo '<img src="'; echo $id1; echo '"width="50" height="50"/>'."<br>"; 
} 

请帮我问候,

找到的代码

$headers = get_headers($filename, 1); 
echo $filename."=".$headers['Content-Length']."<br>"; // size in bytes 
+1

'$ filename'在运行时的值是多少? – mdziekon 2012-07-18 18:24:53

+2

有什么错误?你的输出是什么,给予更多的信息。 – 2012-07-18 18:25:00

+0

$ filename value = http://www.jjbsports.com/pws/client/images/catalogue/products/65014201/zoom/65014201_white.jpg – Fou 2012-07-18 18:26:02

回答

4

的PHP HTTP wrapper不支持stat(),所以喂食HTTP URL时像file_exists()功能不会有任何效果。

如果文件位于本地服务器上,请使用与文件系统相关的文件路径。否则,您不能使用file_exists()