CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 rename uploaded file

Print topic Send  topic

Author Message
Thomas
Posted: 04/13/2005, 9:43 PM

Hi,
As I upload a file name imageA.gif, I would like it to become userX_imageA.gif in my File Folder. Is it possible to do it? If yes, please show me how.

Thanks.
hidran

Posts: 29
Posted: 04/20/2005, 8:58 AM

$old_name=$form_name->field_name->Getvalue();
rename("folder_name/".$old_name,"folder_name/".$new_name);

Yuo can use this piece of code in "After process file" event
View profile  Send private message
Nicole

Posts: 586
Posted: 04/21/2005, 2:23 AM

Thomas,
Keep in mind that in addition to renaming a physical file you need to change its name stored in a database. So change File Upload control value in Before Build Insert/Update events.

_________________
Regards,
Nicole
View profile  Send private message
netaria

Posts: 1
Posted: 06/02/2005, 2:46 PM

After a lot of confusion caused by the order in which things are done and wasting time trying to use FileUpload->SetValue() in Insert/Update, this is how to rename a file in "after process file":

$old=$form->FileUpload->GetValue();
$new="newname.jpg";
rename("File Folder/".$old,"File Folder/".$new);
$db=new clsDBdb(); //or whatever your db class is called
$db->query("update table set filename='".$new."' where filename='".$old."'");

The problem is that if you change the name in Insert/Update, this is done BEFORE the FileUpload Move is executed, which will then have the wrong old_name and fail. The above definitely works!
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.