add info/data to filename on upload

marklandry 20 Sep, 2011
Hi,
I'm trying to change the name of the file that gets uploaded using the CF upload element

Basically, I want to convert the filename to md5 hash, and add some other variable info, then add the .jpg (we're limiting pics to .jpeg only)

can I do something like:

<input type="text" value = "md5('' + <?php echo $my_variable;?>) + 'some other info'">
?

In older versions of CF there was a "Filename Format" parameter for file uploads, but I don't see it in v4

I wanted to check in to see if anyone has dealt with something like this?

Thanx

Mark
marklandry 20 Sep, 2011
I think I found it but I"m too tired to test it...

Added md5 to the following in upload_file_gh.php:

$curly_array['file_name'] = md5(JFile::stripExt($file_post['name']));
GreyHead 20 Sep, 2011
Hi Mark,

Hacking that line will probably do the trick. A 'tidier' way might be to use a Custom Code element to get the file name before the File Upload and write the hashed value into the $form->data array so that you could use {hashed_name} in the File Name box. I think that's possible.

Bob
This topic is locked and no more replies can be posted.