What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP - filename editing on the fly.

Pages: (4): « First [ 1 ] 2 3 4 » Last »
PHP - filename editing on the fly.
Author: Message:
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
O.P. PHP - filename editing on the fly.
Okay so here's the situation.

Whenever I upload via the admin control panel, it will change the filename and change it to a random one that hasn't been used yet. This helps keep the site running smoothly with multiple admins.

Problem is, I get multiple emails a day of people saying the site is great but the random filenames are annoying.

I need to know of a fast and best possible way of changing the filename ON THE FLY, and supplying the user with the new filename.
So the user clicks download, it fetches "12345634hfd.zip" and then edits the filename to "Messenger.zip" and then they get the normal "are you sure you want to download this file - in firefox". Only way I can think of is fetching the file, saving it to another area and then changing the filename and then supplying the user with a new link - but this is slow and could cause errors if more than one person accessed at the same time.

I'm probs thinking too complicated for a simple thing, so maybe you could help me out :)

Thanks
Touch Innovation - touch friendly programs/applications for the windows mobile!


10-19-2008 10:33 PM
Profile E-Mail PM Web Find Quote Report
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
31 / Male / Flag
Joined: Mar 2003
Status: Online
RE: PHP - filename editing on the fly.
mod_rewrite?
YouTube closed-captions ripper (also allows you to download videos!)
10-19-2008 10:42 PM
Profile E-Mail PM Web Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
O.P. RE: PHP - filename editing on the fly.
How would that work? I have over 300 programs + skins that need to change on the fly...
Touch Innovation - touch friendly programs/applications for the windows mobile!


10-19-2008 10:43 PM
Profile E-Mail PM Web Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: PHP - filename editing on the fly.
If you currently download it with PHP, e.g. content-disposition and not just a direct link:

header('Content-Disposition: attachment; filename="Messenger.zip"');
10-19-2008 10:46 PM
Profile PM Find Quote Report
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
31 / Male / Flag
Joined: Jan 2003
RE: PHP - filename editing on the fly.
header("Content-Disposition: attachment; filename=<whateverfilename>");

==

"You have chosen to open <whateverfilename> which is a <whatever type> from <your website>. Open With, Save File"
Spoiler:
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
10-19-2008 10:50 PM
Profile PM Web Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
O.P. RE: PHP - filename editing on the fly.
I'll give you an idea of what I mean just before I try any of these methods (short on time, I have not alot of time to fiddle):

Say we go to:
http://www.touch-innovation.com/details-226-3/
And you go down, and click "Download" It will popup the box to save as and what not. How do I change it when they click there? (It goes via a download counter that edits the mysql db and then redirects to the file)
Touch Innovation - touch friendly programs/applications for the windows mobile!


10-19-2008 10:52 PM
Profile E-Mail PM Web Find Quote Report
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
31 / Male / Flag
Joined: Mar 2003
Status: Online
RE: PHP - filename editing on the fly.
quote:
Originally posted by Nathan
How would that work? I have over 300 programs + skins that need to change on the fly...
Well, your upload script could automatically add a mod_rewrite entry on your .htaccess as soon as a file is uploaded. But this is a very bad solution because your .htaccess file will soon be filled with many entries, possibly making the server slower.

quote:
Originally posted by Nathan
It will popup the box to save as and what not
No it won't :P
It will redirect me to an external link.

Some other issues with the site too:
Text is cut off.
The resolution of the screenshot in the above link messes up the pictures aspect ratio :P

Also, remove that static background :(
It makes Firefox cry :cry:

This post was edited on 10-20-2008 at 05:25 AM by Mike.
YouTube closed-captions ripper (also allows you to download videos!)
10-20-2008 05:24 AM
Profile E-Mail PM Web Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
O.P. RE: PHP - filename editing on the fly.
Meh thats because you have a shitty resolution, it works okay for 1024x768 and upwards.

I'm recoding + redesigning it for the next update anyway, for the time being you can put up with it :P

Static background is fine on my firefox :S


BTW: I didn't give a very good example, this would be a better example:

http://www.touch-innovation.com/details-229-10/
Touch Innovation - touch friendly programs/applications for the windows mobile!


10-20-2008 08:08 AM
Profile E-Mail PM Web Find Quote Report
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: PHP - filename editing on the fly.
why not just make it go to a php file that has the random filename as a parameter then just do the header stuff to get it to download the file?

seems simple enough to me =\
10-20-2008 08:10 AM
Profile PM Find Quote Report
ryxdp
Senior Member
****


Posts: 804
Reputation: 16
29 / Male / Flag
Joined: Jun 2006
RE: RE: PHP - filename editing on the fly.
quote:
Originally posted by Nathan
Static background is fine on my firefox :S

use
background-attachment: scroll;

it makes scrolling a hell of a lot easier :P
10-20-2008 09:05 AM
Profile PM Find Quote Report
Pages: (4): « First [ 1 ] 2 3 4 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On