Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opendir error; No such file or directory found

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 />";
like image 956
stevieD Avatar asked Jan 17 '23 13:01

stevieD


1 Answers

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.

like image 167
Your Common Sense Avatar answered Jan 31 '23 09:01

Your Common Sense