If you have PHP available here are a couple of options.
http://www.finalwebsites.com/snippets.php?id=4
http://www.ironclad.net/scripts/
Here is a version similar to the first link I use, set up for pdf extension.
To alter for other types alter $extenstion=
and Content-type:
and folder where content is /pdf/
Code:
<?php
// place this code inside a php file and call it f.e. "download.php"
$filename = $_GET['file'];
$extension = ".pdf";
$path = $_SERVER['DOCUMENT_ROOT']."/pdf/"; // play with the path if the document root does noet exist
$fullPath = $path . $filename . $extension;
if ($fd = fopen ($fullPath, "r")) {
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
$ext = strtolower($path_parts["extension"]);
switch ($ext) {
case "pdf":
header("Content-type: application/pdf"); // add here more headers for diff. extensions
header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachement' to force a download
break;
default;
header("Content-type: application/octet-stream");
header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
}
header("Content-length: $fsize");
header("Cache-control: private"); //use this to open files directly
while(!feof($fd)) {
$buffer = fread($fd, 2048);
echo $buffer;
}
}
fclose ($fd);
exit;
//link to file example: http://www.example.com/download.php?file=file-name
?>
Last edited by GeekSpecialties; 06-18-2009 at 11:33 PM..
|