SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
-
Aug 26, 2001, 00:51 #1
- Join Date
- Apr 2000
- Location
- Los Angeles, California
- Posts
- 1,008
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Passing binary/text to download function, in PHP?
Can I grab a text or binary file from a PHP file and pass it on to the browser as to be downloaded so that the browser pops up and asks where you want it to be saved? If so how?
Thanks.
-
Aug 26, 2001, 02:40 #2
All you need is to echo the folowing:
header("location: yourfile.zip");
-
Aug 26, 2001, 10:32 #3
- Join Date
- Apr 2000
- Location
- Los Angeles, California
- Posts
- 1,008
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Two problems:
1) It must be done before you send anything else (i dont want to here about the buffer thingy you can turn on and all that, i am just saying that all in all this is bad)
2) All that does is forward to a page. So if its a php page it will just be displayed, instead of having the browser pop up to have it download.
Any other suggestoins?
-
Aug 26, 2001, 14:28 #4
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Make a file named whatever(I named mine dl.php) and stick this in it.
PHP Code:<?
header("204 No Content");
header("Content-Disposition: attachment; filename=\"".$file."\"");
readfile($file);
?>
<a href="dl.php?file=filename.gif">download file</a>Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Aug 27, 2001, 13:30 #5
- Join Date
- Apr 2000
- Location
- Los Angeles, California
- Posts
- 1,008
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Okay, this sounds like it is going to work perfectly. Thanks!
Bookmarks