函数file_exists在php中不起作用
发布时间:2020-12-13 16:17:11 所属栏目:PHP教程 来源:网络整理
导读:我一直试图找到目录中的file_exist.如果不是我想使用不同的图像.但是当我使用file_exists函数时,它总是返回false. 我用的代码是 while($r=mysql_fetch_row($res)) { if(!file_exists('http://localhost/dropbox/lib/admin/'.$r[5])) { $file='http://localho
我一直试图找到目录中的file_exist.如果不是我想使用不同的图像.但是当我使用file_exists函数时,它总是返回false.
我用的代码是 while($r=mysql_fetch_row($res)) { if(!file_exists('http://localhost/dropbox/lib/admin/'.$r[5])) { $file='http://localhost/dropbox/lib/admin/images/noimage.gif'; } else $file='http://localhost/dropbox/lib/admin/'.$r[5];} 但即使文件退出,该函数也始终返回false.我通过使用检查了 <img src="<?php echo 'http://localhost/dropbox/lib/admin/'.$r[5]; ?>" /> 这样可以正确显示图像. 请有人帮帮我 解决方法
您正在将URL传递给file_exists函数,这是错误的.而不是传递文件夹的本地路径.
while($r=mysql_fetch_row($res)) { if(!file_exists('/dropbox/lib/admin/'.$r[5])) { $file='/dropbox/lib/admin/images/noimage.gif'; } else $file='/dropbox/lib/admin/'.$r[5]; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |