Okay so the code is able to generate the files but I have a problem with files that are saved with space...when user clicks on the link it says page not found...example a file with a filename of "research proposal" gives the error Not Found The requested URL /simpleblog/kcfinder/upload/files/ was not found on this server....pretty sure its because of the space..
(-3-)

<?php
// directory path can be either absolute or relative
$dirPath = '../kcfinder/upload/files';
echo "<h1>DATA FILES</h1><hr>";
// open the specified directory and check if it's opened successfully 
if ($handle = opendir($dirPath)) {

   // keep reading the directory entries 'til the end 
   while (false !== ($file = readdir($handle))) {

      // just skip the reference to current and parent directory 
      if ($file != "." && $file != "..") {
         if (is_dir("$dirPath/$file")) {
            // found a directory, do something with it? 

           echo "<a href=".$dirPath."/".$file.">$file<br></a>";

         } else {
            // found an ordinary file 

             echo "<a href=".$dirPath."/".$file.">$file<br></a>";
         }
      }
   }

   // ALWAYS remember to close what you opened 
   closedir($handle);
}
?>

Recommended Answers

All 2 Replies

If the file existed in the right place and was filled with correct content, it would display fine.

Your code above is unclear, if you are presumably wanting to view the content of a file use file_get_contents($url_to_file);. You might need to expand on your objectives if you want more help.

ohh no worries I found a way out of the problem...:3

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.