Changing the image name

See all posts Reply

Changing the image name new!
by Ben, 17 years, 10 months ago
Hi, how can I change the name of the uploaded file? i.e. "avatar.jpg". How can I always rewrite it?

ThanksReply
Re: Changing the image name new!
by colin, 17 years, 10 months ago
Please read the documentation.

To rename a file, use:
$foo->file_new_name_body = 'avatar';

To append a string to the filename, use:
$foo->file_name_body_add = '_avatar';

To change a file extension:
$foo->file_new_name_ext = 'ext';

To force the filename to something specific:
$foo->file_overwrite = true;
$foo->file_auto_rename = false;
(This allows overwriting, and deactivates the auto-renaming feature. You need to set up both in order to upload a file and be sure that it will be always overwriting the same file and keep the same filename)Reply
Re: Changing the image name new!
by Mitchel Verschoof, 14 years, 2 months ago
Ok, now.
I gave the file a new name:
$image_name=time().'.'.$_FILES['image']['name'];
$foo->file_new_name_body = 'big_'.$image_name;

2 things:

1. he will rename it to: big_1285020073Afb076jpg.jpg
so thats 2 times jpg, and i just want it one time/

2. How to put the new name in database?Reply
Re: Changing the image name new!
by colin, 14 years, 2 months ago
1. Maybe something like this... it all depends on the original name you have for the image.
$image_name=time().'.'.$foo->file_new_name_ext;
$foo->file_new_name_body = 'big_'.$image_name;

2. This question is out of scope in this forumReply
Re: Changing the image name new!
by Ben, 17 years, 10 months ago
Maybe I will read the whole class, all answers are in!

Thank you Colin,

Ben, french new userReply
Re: Changing the image name new!
by colin, 17 years, 10 months ago
Salut ;)Reply