how to rename file at run time

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
eshban
Forum Contributor
Posts: 184
Joined: Mon Sep 05, 2005 1:38 am

how to rename file at run time

Post by eshban »

i have a php form , in which i have some controls. On a form there is a "File Field" control. When user select any file from browse button, the file will be uploaded successfully.

But i need some modifications.

I want that when user upload a new file, the php code rename the file and add some random string with the file name.

How can i do this, i spend many time on this module, but i am unable to do it.

Please help in this regard.
Thanks
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

(#10850)
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post by Gente »

What are you using for upload?
move_uploaded_file() ?
This way I don't understant what is the problem to change the second parameter.
eshban
Forum Contributor
Posts: 184
Joined: Mon Sep 05, 2005 1:38 am

Post by eshban »

i use "COPY" command to upload files
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post by Gente »

The same situation. Specify the destination name in the 2nd parameter of copy().
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

copy() is not intended for use with uploads. Use move_uploaded_file().
Post Reply