打开目录错误;找不到这样的文件或目录
这可能是一个非常简单的问题。我在目录 /mobile 中工作,并且在目录 /uploads 中有照片。
我收到错误:
警告:opendir(http://www.yoozpaper.com/uploads) [function.opendir]:无法打开目录:未在 /hermes/bosweb/web088/b881/ipg 中实现。 yoozpapercom/mobile/sportspage.php 第 313 行
我将其放入变量 $dir = "http://www.yoozpaper.com/uploads"
对于图像src=$dir/$file
。
请注意,当我处理主目录中的文件时,这是有效的。
对此的任何帮助将不胜感激。
代码如下:
$dir = "http://www.yoozpaper.com/uploads";
//打开目录
if ($opendir = opendir($dir))
{
//读取目录
while (($file = readdir($opendir)) !==FALSE)
{
if ($file==$imagename)
//下面可以指定高度和宽度
echo "<img width='75%' height='30%' src='$dir/$file' title='$headline - Yoozpaper News Online' alt='$headline'><br /><br />";
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 />";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须了解文件系统和HTTP 守护进程之间的区别。
虽然外表有些相似,但本质上却是不同的。
要使用 opendir,您必须打开*目录,而不是 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.
To use opendir, you have to open *a directory, not HTTP resource.
should work
would be better as it will always point to the uploads directory, no matter from where you called it.
http://www.yoozpaper.com/uploads 我们是 URL,而不是目录。您无法使用 opendir 访问它。您需要它的系统路径,例如“/home/user/public_html/uploads”或其他内容。使用文件管理器或控制面板获取目录路径
在您的情况下可能是“/hermes/bosweb/web088/b881/”。但我不确定。无论如何,获取本地路径
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