未找到 PHP 错误对象 [英] PHP error object not found
问题描述
我创建了一个小的 PHP 文件,该文件将目录中的文本文件的名称显示为 first.txt
、second.txt
、third.txt代码>.单击任何文件时,我收到错误找不到对象".
I have created a small PHP file which displays the name of text files in a directory as first.txt
, second.txt
, third.txt
. On clicking on any of the files I get the error "object not found".
这不起作用:
localhost/Applications/XAMPP/xamppfiles/htdocs/Learning/ListingFiles/first.txt
但这有效:
file:///Applications/XAMPP/xamppfiles/htdocs/Learning/ListingFiles/first.txt
你能帮我了解一下哪里出了问题吗?
Can you help me to understand what is wrong?
这是我的代码:
<?php
$directory = '/Applications/XAMPP/xamppfiles/htdocs/Learning/ListingFiles';
if ($handle = opendir($directory.'/')){
echo 'Looking inside'.$directory.'<br>';
while ($file = readdir($handle)){
if ($file != '.'&&$file != '..'){
echo '<a href="'.$directory.'/'.$file.'">'.$file.'</a><br>';
}
}
}
?>
以下是日志文件的一些更新
Following is some updates of log file
- [Thu Jul 18 01:06:57 2013] [error] [client ::1] 文件不存在:/Applications/XAMPP/xamppfiles/htdocs/xampp/xamppfiles
- [Thu Jul 18 01:15:14 2013] [error] [client ::1] 文件不存在:/Applications/XAMPP/xamppfiles/htdocs/Applications,referer:localhost/learning/ListingFiles/file.php
- [Thu Jul 18 01:15:43 2013] [error] [client ::1] 文件不存在:/Applications/XAMPP/xamppfiles/htdocs/Applications,referer:localhost/learning/ListingFiles/file.php
- [Thu Jul 18 01:17:13 2013] [error] [client ::1] 文件不存在:/Applications/XAMPP/xamppfiles/htdocs/Applications,referer:localhost/learning/ListingFiles/file.php
- [Thu Jul 18 01:39:04 2013] [error] [client ::1] 文件不存在:/Applications/XAMPP/xamppfiles/htdocs/learning/ListingFiles/function.opendir,referer:localhost/learning/ListingFiles/file.php
推荐答案
尝试使用
$dir = "/Applications/XAMPP/xamppfiles/htdocs/learning/";
作为包含文件的主路径.
as your main path with the files in it.
这个完整路径或../learning"应该能让你找到你的文件的正确目录.
This full path or "../learning" should get you to the right directory to your files.
创建链接时,您需要使用/learning/"+ 文件名来提供文件路径.
When creating a link you'll want to use "/learning/" + filename to give the path to the file.
谢谢,我的流
这篇关于未找到 PHP 错误对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!