Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Renaming file before send to user?


dmorison - 2:19 pm on Jul 14, 2011 (gmt 0)


Hi Ted,

That's exactly the header to use.

Let's say you know the original filename as $filename, and the path to the hashed copy as $hashed_filename, you could serve it with the original filename as follows:


header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$filename);
readfile($hashed_filename);
exit();


Remember that when sending header()'s your code must not have generated any output prior to that point...


Thread source:: http://www.webmasterworld.com/php/4339486.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com