Page 1 of 1
upload name vs the prettyname
Posted: Mon Mar 30, 2009 10:15 am
by mlecho
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
Re: upload name vs the prettyname
Posted: Mon Mar 30, 2009 10:22 am
by atonalpanic
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'
Re: upload name vs the prettyname
Posted: Mon Mar 30, 2009 10:31 am
by mlecho
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
Posted: Mon Mar 30, 2009 2:30 pm
by pickle
Point the download link to a PHP file with a $_GET variable that is the unique filename, such as:
Code: Select all
<a href = "downloadProxy.php?file=200903302-1">Download "2009.doc"</a>
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!
Re: upload name vs the prettyname
Posted: Mon Mar 30, 2009 6:49 pm
by mlecho
oui, c'est parfait
thanks.