[thelist] PHP force download of file?

Ivo P ipletikosic at gmail.com
Tue Feb 15 18:23:33 CST 2005

I've handled it is this way & works like a charm so far:

Header( "Content-Type: application/octet-stream" );
Header( "Content-Length:" . filesize( $filepath ) );
Header( "Content-Disposition: attatchment; filename=$filename" );
readfile( $filepath );

On Tue, 15 Feb 2005 16:34:26 -0500, Theodore Serbinski
<stanson at gmail.com> wrote:
> Ok guys, got a question here. I'm working on a script for a client
> that will allow them to upload files (doc, txt, and a few other
> extensions) and I have a script that reads the folder and prints out a
> list of all docs and sizes.
> Now what I want to do is make each file name a link to the file, that
> promps them to "open or save" the document... like any other
> downloadable file on the internet. What is the best way to do this
> with PHP? File sizes are going to range any where from a few bytes up
> to around 50MB. I'm assuming I'll need to force a download? I don't
> need to worry about mime-types do I (since I don't want say Adobe to
> open on a PDF file unless the user clicks open instead of save to
> disk)?
> I know because of server memory, I need to be careful and there seems
> to be a great function to chunkify these files instead of loading them
> all at once into memory here:
>     http://www.php.net/readfile (first comment)
> Any tips/suggestions for this would be great. Thanks!
> ted
> --
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !

More information about the thelist mailing list