Page 1 of 1

Rename file before download. Dont even know where to start

Posted: Sun Jun 03, 2007 9:09 pm
by bsprogs
I've made a private file upload site for myself and a few friends.

When a file is uploaded, I have the script change the file name to a random name. It then stores that name along with the user id and original file name in a database.

What I need to do now is when someone clicks to download the file I want it to show as as the original file name before they download it so they can save it as the original file name.

Example:

I upload "CarFun.mpeg".
After being uploaded, it's saved as "82bs88sns89ua.mpeg"

I click to download the file and I want it to say:
Save as: "CarFun.mpeg"

Any thoughts? I'm stumped.

Posted: Sun Jun 03, 2007 9:12 pm
by feyd
header() provides the ability to specify what filename the browser should "guess" to name it.

You're looking for the Content-Disposition header.

Posted: Sun Jun 03, 2007 11:00 pm
by bsprogs
feyd wrote:header() provides the ability to specify what filename the browser should "guess" to name it.

You're looking for the Content-Disposition header.
Thank you so much! That just saved me a very long time.