Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Renaming files using PHP (http://www.go4expert.com/forums/renaming-files-using-php-t21244/)

suhas93 7Mar2010 20:26

Renaming files using PHP

I have a file on another server (say "something.com/1122.doc")

Can I have a renaming engine (using PHP?) So, that when visitors click on download, the file should be renamed to somethingmeaningful.doc


loyo 8Mar2010 19:04

Re: Renaming files using PHP
In your download script, you can give a new name to something.com/1122.doc, when somebody visited this script, it should copy the Original file to the target file,and then ,use the function header("location: newfilename path"); to visit the new file.
copy("1122.doc", "newfile.doc");
header("location: newfile.doc");

suhas93 10Mar2010 16:45

Re: Renaming files using PHP
thank you! thats a great idea!

is there a script that deletes the file after download?

ok i'm cheap :happy:

loyo 12Mar2010 00:28

Re: Renaming files using PHP
try unlink("newfile.doc"); after performing header();
I don't know whether it can achieve you need.

All times are GMT +5.5. The time now is 17:49.