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".
This does not work:
localhost/Applications/XAMPP/xamppfiles/htdocs/Learning/ListingFiles/first.txt
But this works:
file:///Applications/XAMPP/xamppfiles/htdocs/Learning/ListingFiles/first.txt
Can you help me to understand what is wrong?
Here is my code:
<?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] File does not exist: /Applications/XAMPP/xamppfiles/htdocs/xampp/xamppfiles
- [Thu Jul 18 01:15:14 2013] [error] [client ::1] File does not exist: /Applications/XAMPP/xamppfiles/htdocs/Applications, referer: localhost/learning/ListingFiles/file.php
- [Thu Jul 18 01:15:43 2013] [error] [client ::1] File does not exist: /Applications/XAMPP/xamppfiles/htdocs/Applications, referer: localhost/learning/ListingFiles/file.php
- [Thu Jul 18 01:17:13 2013] [error] [client ::1] File does not exist: /Applications/XAMPP/xamppfiles/htdocs/Applications, referer: localhost/learning/ListingFiles/file.php
- [Thu Jul 18 01:39:04 2013] [error] [client ::1] File does not exist: /Applications/XAMPP/xamppfiles/htdocs/learning/ListingFiles/function.opendir, referer: localhost/learning/ListingFiles/file.php
localhost
is part of the file structure on the machine.. have you triedApplications/XAMPP/xamppfiles/htdocs/Learning/ListingFiles/first.txt
? – user20232359723568423357842364