[thelist] PHP force download of file?

Theodore Serbinski stanson at gmail.com
Tue Feb 15 15:34:26 CST 2005

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

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!


More information about the thelist mailing list