hi- i have a tool used or uploading files. Upon a successful upload, the files have timestamps for names. For example, a file may be called: 20090330080418. In our db, i'm giving each file a 'prettyname' as well. My question: when giving a user the opportunity to download file 20090330080418, how can i rename it on the fly, or at least make the download dialogue look like the 'pretty name'? can i rename the anchor to have an href of the prettyname?
thanks
upload name vs the prettyname
Moderator: General Moderators
-
atonalpanic
- Forum Commoner
- Posts: 29
- Joined: Mon Mar 02, 2009 10:20 pm
Re: upload name vs the prettyname
Are you worried at all about files having the same pretty name?
How pretty is your pretty name? I.e. will it be renamed to words like '2008 report.doc'
or do you define pretty as just a smaller name like the way tinyurl creates small names such as '2D8Av'
How pretty is your pretty name? I.e. will it be renamed to words like '2008 report.doc'
or do you define pretty as just a smaller name like the way tinyurl creates small names such as '2D8Av'
Re: upload name vs the prettyname
pretty name would indeed be like '2008 report.doc'. I was not too worried about similar pretty names, as the important one is the unique name for the actual file- the timestamped name. Because the true names (timestamped) are unique, these are the ones that must not be altered. Pretty names can be edited at will.
Re: upload name vs the prettyname
Point the download link to a PHP file with a $_GET variable that is the unique filename, such as:
That PHP file then does a lookup to see what the pretty filename is. It can then send headers which can force a download as the pretty file name. Then get the PHP file to readfile() the actual file on the filesystem, and voila!
Code: Select all
<a href = "downloadProxy.php?file=200903302-1">Download "2009.doc"</a>Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: upload name vs the prettyname
oui, c'est parfait
thanks.
thanks.