Forums

Stop files from being renamed on upload.

mike80925 23 May, 2014
I have created a simple form that will upload files to a folder on my server. But it is renaming the files before they get there. Is there a way to stop chronoforms from renaming the file after it has been uploaded?
GreyHead 24 May, 2014
Hi mike80925,

I don't' see anything configurable in CFv5 - there is some code in the Upload Files action that doesn't seem to have been implemented. It might be possible the hack the code, or to add some custom code to re-rename the files back to the original. What are the changes you are seeing?

Bob
mike80925 26 May, 2014
It appears to be adding the date it was uploaded and another number.
GreyHead 26 May, 2014
Answer
2 Likes
Hi mike80925,

I think that at the moment you'd have to hack the code :-(

If you comment out these lines around line 141 of /administrator/components/com_chronoforms5/chronoforms/actions/file_upload/file_upload.php that should do it
		//mask the file name
		if(strlen($this->config->get('forced_file_name', '')) > 0){
			$file_name = str_replace('FILE_NAME', $file_name, $this->config->get('forced_file_name', ''));
		}else{
			$file_name = date('YmdHis').'_'.$file_name;
		}


Bob

PS The 'another number' is the upload time - the date-time added because there are potential problems if users upload files with the same name.
mike80925 27 May, 2014
Thanks I will try this tomorrow.
mike80925 28 May, 2014
Thanks it worked I only had to comment out the else statement for it to work. If I commented out the whole thing it failed.
doromi 25 Jun, 2014
Pity ... For CF4 some great guy had written the Files Upload GH ...😉
And now we have to hack the code...

Still... Thanks, Bob, for your kind help.
GreyHead 25 Jun, 2014
HI doromi.

I'm part of the way through writing my first custom action for CFv5 (it's more or less my latest CSV Export [GH] action from CFv4). I have most of it working but it's been a slow process re-learning how the code works in CFv5 without using the Joomla! methods that I'm familiar with.

Hopefully once I have that one complete it will be easier to re-create some of my other custom actions.

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