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
|
 |
 |
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 |
 |
 |
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!
|
 |
 |
|