Published in: PHP
URL: http://www.mechanicmatt.com/drg_2008/
so lets say you saved this script in your document root as "dlFile.php". so it's located at yourdomain.com/dlFile.php
and your files are located at yourdomain.com/files/
then you would link to it like this
href="dlFile.php?filename=podcast1.mp3". If your file is in a subdirectory of /files/ then you'd use
dlFile.php?filename=subDir/filename.jpg
Refer to the comment in the php script to specify the path where the files are stored.
<?php if ($_REQUEST["filename"] != "") { if ($filename != "") { /* this is where you set the base path and the file for security reasons. If you wish to manually hard code a base path, then comment out the following line, and use the line after it */ //$file = "/var/www/htdocs/audio/" . $filename; header ("Content-disposition: attachment; filename=" . str_replace(" ", "_", basename($file)) . ";"); } else { echo ' <script type="text/javascript"> <!-- alert("' . $file . '\n\nI do not currently have this image ready for download"); --> </script> '; } } else {} } else {} ?>
You need to login to post a comment.
