homepage Welcome to WebmasterWorld Guest from 174.129.103.100
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
rename file on download
mcnika




msg:3920325
 2:30 pm on May 26, 2009 (gmt 0)

Then I upload the file, for example "MG_CV.doc" the php code renames the file to "38912831_7183791.doc" and then uploads it. In database are saved the old and new names of the files (MG_CV.doc, 38912831_7183791.doc).

After I call
<a href='MG_CV.doc'>download file</a>
I need on clicking on "download file" download 38912831_7183791.doc but in "save as dialog" must be "MG_CV.doc" how can I do this in PHP.

 

rocknbil




msg:3920432
 4:51 pm on May 26, 2009 (gmt 0)

1. store the real file name and the original file name in a database.

2. Don't directly link to the file, link to a script that opens the DB, gets the real file name and the original file name.

3. Use one of the open methods to open the file and print to the browser. This will allow you to secure the files too, if needed.

4. When outputting the download dialog, populate the "filename" attribute in the header.

One example here [webmasterworld.com] from a recent thread

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved