Opendir错误;找不到这样的文件或目录 [英] Opendir error; No such file or directory found

查看:1491
本文介绍了Opendir错误;找不到这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个非常简单的问题。我在目录/手机上工作,我在目录/上传中有照片。

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

我收到错误:

警告:opendir(http://www.yoozpaper.com/uploads)[function.opendir]:无法打开目录:未在/ hermes / bosweb / web088 / b881 / ipg中实现。第313行的yoozpapercom / mobile / sportspage.php

我把它放入变量$ dir = http ://www.yoozpaper.com/uploads

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

图片 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.

以下代码:

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

//打开目录

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

//读取目录

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 />";


推荐答案

您必须了解 a之间的区别文件系统 HTTP守护程序

虽然外观有些相似,但绝对不同。

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

要使用opendir,您必须打开* 目录,而不是HTTP资源。

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

opendir('../uploads');

应该有效

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

会更好,因为它总是指向uploads目录,无论你从哪里调用它。

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

这篇关于Opendir错误;找不到这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆