upload name vs the prettyname

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mlecho
Forum Commoner
Posts: 53
Joined: Wed Feb 02, 2005 9:59 am

upload name vs the prettyname

Post 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
atonalpanic
Forum Commoner
Posts: 29
Joined: Mon Mar 02, 2009 10:20 pm

Re: upload name vs the prettyname

Post 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'
mlecho
Forum Commoner
Posts: 53
Joined: Wed Feb 02, 2005 9:59 am

Re: upload name vs the prettyname

Post 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.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: upload name vs the prettyname

Post 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!
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
mlecho
Forum Commoner
Posts: 53
Joined: Wed Feb 02, 2005 9:59 am

Re: upload name vs the prettyname

Post by mlecho »

oui, c'est parfait

thanks.
Post Reply