How can I set a file to automatically download instead of opening in the browser. I have files that are for a specific program, and as such have unique file extensions. Any help would be greatly appreciated.
File Download
Not sure about your file extensions but having it open in the same window can be done very simply
Why not put everything in a zip and/or tar.gz? Less disk space and quicker download for users using less bandwidth.
| Code: |
| <a href="FILE_URL" target="_self">FILE_NAME</a> |
Why not put everything in a zip and/or tar.gz? Less disk space and quicker download for users using less bandwidth.
The simplest method is telling your clients to download the file. For example:
whatever.yzr - Right click on this link, then choose Save As...
whatever.yzr - Right click on this link, then choose Save As...
Nyizsa, Thats what I was thinking, but I was wondering if there was a way to have it done automatically.
Thanks for the input.
Thanks for the input.
You can easily do this in php.
This code from http://lists.evolt.org/archive/Week-of-Mon-20020513/112746.html
[theLIst]
| Code: |
| If you can use PHP, you can do this through the header() function - you
would pass $file to a page containing the code below - e.g. <a href="download.php?file=foobar.mp3">download foobar</a> the PHP code in download.php : <?php urlencode($file) ."\";',1000);"; $f = @fopen($file,"r"); if (!$f) print "<HTML><BODY>Failed to download $file</BODY></HTML>"; else { header("Content-Type: application/octet-stream"); header("Content-Length: ".filesize($file)); header("Content-Disposition: attachment; filename=" .basename($file)); $data=""; while (!feof($f)) $data.=fread($f,64000); fclose($f); print $data; } ?> |
This code from http://lists.evolt.org/archive/Week-of-Mon-20020513/112746.html
[theLIst]
eepman, this is exactally what I was looking for. thanks.
