how to read files from a directory on the local server in php?

alexandre r

New member
I want to read files such as software setups, media files from a folder called Softwares. this folder is located in htdocs and in the website folder. I want these files to appear on a page where people could download them. I tried the following code but it not work:

<?php

echo "<tr><td>$file</td></tr><tr><td><a href=\"$file\" target=\"_blank\"><img src=\"$file\" border=\"0\"> </a></td></tr>";
//$path="/Softloads/Softwares/";
if ($handle = opendir('/Softwares/')) {
echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
while (false !== ($file = readdir($handle)))
{
if (!is_dir($file))
{
if ($file != "." && $file != "..")
{
echo "<tr><td>$file</td></tr><tr><td><a href=\"$file\" target=\"_blank\"><img src=\"$file\" border=\"0\"> </a></td></tr>";
}
}
}
echo "</table>";
closedir($handle);
}
?>

when I preview it I get this message:

Warning: opendir(/Softwares/) [function.opendir]: failed to open dir: No error in C:\xampp\htdocs\softload\triedirectory.php on line 19

what should I do
 
Back
Top