Page 1 of 1

Append Field Value to Filename

Posted: Feb 10th, '12, 03:55
by cateappstech
After reading the forum I am getting snippets that I can't quite piece together, so I am going to ask for help.

I have a data column called: product_code

I only add images in 'edit' mode so that the product_code already exists.

If for example product_code = "doll", I wish to be able to identify images easily, so I would like the filename to be "doll-imagename.jpg"

(Note: this is only an example, so its not a case of just typing in "doll-imagname.jpg" :D )

I am sure this can be done simply... Please tell me the efficient way to do this

Thanks

Re: Append Field Value to Filename

Posted: Feb 12th, '12, 08:16
by administrator

Re: Append Field Value to Filename

Posted: Jun 21st, '12, 17:23
by harryo
Hello,

This is appending to a string, which works great! But can you also append a field value to the original uploaded filename? For example:

The file uploaded is: myDoc.pdf

I would like to save as myDoc_1234.pdf where "1234" is the value of another field. So I can retain the original filename.

Can this be done?

Thank you!

Re: Append Field Value to Filename

Posted: Jun 21st, '12, 20:14
by administrator
Yes, try following:
Set unique value for uploaded image:

a) 'file_name'=>'img_'.((isset($_GET[$unique_prefix.'mode']) && ($_GET[$unique_prefix.'mode'] == 'add')) ? $dgrid->GetNextId() : $dgrid->GetCurrentId())

b) 'file_name'=>'img_'.((isset($_GET[$unique_prefix.'mode']) && ($_GET[$unique_prefix.'mode'] == 'add')) ? $dgrid->GetRandomString('10') : $dgrid->GetRandomString('10'))