Opendir error; No such file or directory found

北战南征 提交于 2019-12-22 08:41:02

问题


This may be a very easy question. I am working in directory /mobile and I have photos in a directory /uploads.

I am getting the error:

Warning: opendir(http://www.yoozpaper.com/uploads) [function.opendir]: failed to open dir: not implemented in /hermes/bosweb/web088/b881/ipg.yoozpapercom/mobile/sportspage.php on line 313

I am putting this into a variable $dir = "http://www.yoozpaper.com/uploads"

for the image src=$dir/$file.

Note that this is working when I am working with files in the main directory.

Any help on this would be greatly appreciated.

Code below:

$dir = "http://www.yoozpaper.com/uploads";

//open directory

if ($opendir = opendir($dir))
{

//read directory

while (($file = readdir($opendir)) !==FALSE)
{

if ($file==$imagename)

//can specify height and width below

echo "<img width='75%' height='30%' src='$dir/$file' title='$headline - Yoozpaper News Online' alt='$headline'><br /><br />";

回答1:


You have to understand the difference between a filesystem and an HTTP daemon.
Although they have somewhat similar appearance, it is absolutely different matters.

To use opendir, you have to open *a directory, not HTTP resource.

opendir('../uploads');

should work

opendir($_SERVER['DOCUMENT_ROOT'].'/uploads');

would be better as it will always point to the uploads directory, no matter from where you called it.




回答2:


http://www.yoozpaper.com/uploads us a URL not a directory. You can't access it using opendir. You need the system path to it for example "/home/user/public_html/uploads" or something. Get the path to the directory using your file manager or control panel

It might "/hermes/bosweb/web088/b881/" in your case. m not sure though. In any case, get the local path



来源:https://stackoverflow.com/questions/9155992/opendir-error-no-such-file-or-directory-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!