Reply
Rename File on Download
Old 05-04-2007, 01:01 AM Rename File on Download
Extreme Talker

Posts: 153
I have a php script that uploads a file to a directory. Since this program doesn't like spaces and crazy characters in the file name, the name gets changed to the current timecode (funky named-4.jpg to 1178253719.jpg). After the change i save both names to a db. This all works great. Next i have a page that reads the directory and displays the timecoded file name, when a user clicks it, it downloads fine. still works great.

I would like to find a way to rename the file on download, to the old saved named of the file (1178253719.jpg to funky named-4.jpg). How can i do this? Thanks.
empiresolutions is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 05-04-2007, 01:19 AM Re: Rename File on Download
jito's Avatar
MY LIFE IS 'i' LIFE

Posts: 551
Name: surajit ray
Location: inside the heart of my friends
What do you want? go back to the old name. Then you need to tore that name somewhere.
__________________
Think+, work +, but not HIV + :)
jito is offline
Reply With Quote
View Public Profile
 
Old 05-04-2007, 02:17 AM Re: Rename File on Download
Extreme Talker

Posts: 153
i have the old name stored. i need to rename it to the stored version on click(download).
empiresolutions is offline
Reply With Quote
View Public Profile
 
Old 05-04-2007, 02:46 AM Re: Rename File on Download
Extreme Talker

Posts: 153
heres the fix.

http://www.higherpass.com/php/Tutori...load-Security/
empiresolutions is offline
Reply With Quote
View Public Profile
 
Old 05-04-2007, 07:25 AM Re: Rename File on Download
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
you don't actualy rename the file on download .. you just use headers to say to the browser the name of the file being dowloaded

PHP Code:
$showname='the_file_name_the_download_file_will_have.jpg';
$downloadurl 'the url to the file being dowloaded';
$size filesize($downloadurl);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$showname."\";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$size);
readfile($downloadurl); 
__________________
If you like my posts ... TK is appreciated:)
Web Directory | Blog
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Reply     « Reply to Rename File on Download
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12514 seconds with 12 queries