Using the script below, I want to enable site users to download files. I am able to upload the files to the specified directory, and the permissions on this directory are 777. However, files that are downloaded cannot be opened, and an error window appears stating that the file cannot be accessed or has read-only permission.
I have look at some different scripts, and I think that all that I am missing is some type of reference to header information.
revez
<?php
$current_dir = "content/documents/upload_files/";
$dir = opendir($current_dir);
while (false !== ($file = readdir($dir))) {
if($file == $doc_name) {
if($file != "." && $file != "..") {
fopen($current_dir.$file, "rw");
echo "<a href=\"content/documents/upload_files/$file\">$file</a><br>";
}
}
}
closedir($dir);
?>