Redirecting downloads to original filename

From: Date: Thu, 08 Aug 2002 18:57:15 +0000
Subject: Redirecting downloads to original filename
Groups: php.general 
Request: Send a blank email to php-general+get-111717@lists.php.net to get a copy of this message
Hey folks, Have a bit of a problem here that I just can't figure out. Scenario: I'm writing a file upload/download portal, pulling data from Interbase on an IIS server. At the moment, when a user uploads a file, I store the original filename in the database (brought out again by the script as $OrigName), and rename the physical file to a random filename (named $sFilePath in my PHP script), in order to avoid conflicts. The client now wants the end-user to be given the original filename when they download it, and I can't figure out how to do it! For the purposes of this problem, let's assume that $sFilePath = '/filebase/pn000fe3.exe' and $OrigName='filename.exe'. At the moment, I'm simply using header("Location: $sFilePath"); to redirect the user to the physical file (the random filename). I'd love it if there were some way to have the user download the file in $sFilePath, but have the browser think the filename is actually the file in $OrigName. I've toyed around with the idea of simply creating a copy of the file, and placing it in a temporary directory, but that seems like a last-case attempt, due to clean-up issues (when do you know the download is done? When do you schedule deletion for? etc) I'll be checking back on the thread, but please cc all replies to darren.harkness@matrikon.com. Thanks in advance for any help given.

« previous php.general (#111717) next »