homepage Welcome to WebmasterWorld Guest from 54.211.231.221
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Rename file name before upload
mcnika




msg:3602659
 7:40 am on Mar 17, 2008 (gmt 0)

Hi.
I need PHP code, that will let me rename file, when upload it to an exactly folder.I mean when i choose the file that i'll upload it, it must change the name and then upload it.

 

Habtom




msg:3602678
 7:49 am on Mar 17, 2008 (gmt 0)

If you have the copy function somewhere on your upload script, you can rename the file as you copy it.

copy($source, $target);

mcnika




msg:3602734
 10:07 am on Mar 17, 2008 (gmt 0)

Suppose that you have "flower.jpg" image in the folder.
I click on Browse and choose image with the same name "flower.jpg"
and click submit.The code must check if there is a such file on the folder, if yes rename it and upload. The checking code I've already written.
The function that you wrote would help me if I'd like to change the name of the first image.

phranque




msg:3602737
 10:14 am on Mar 17, 2008 (gmt 0)

welcome to WebmasterWorld [webmasterworld.com], mcnika!

you cannot change the name of a file before you upload it.

when you upload a file the script must create a file and write the uploaded data to the file.
you can name the newly created file anything you like when you create it...

Habtom




msg:3602762
 10:28 am on Mar 17, 2008 (gmt 0)

The function that you wrote would help me if I'd like to change the name of the first image.

if yes rename it and upload

Are you trying to name the existing file, if there the new file is having the same file name as the one already in the server?

rename('flower.jpg', 'flower2.jpg');

Habtom




msg:3602765
 10:33 am on Mar 17, 2008 (gmt 0)

PHP manual Rename [php.net]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved