Rename uploaded file

Gatsman 20 May, 2014
I found an issue with my upload file form.
A user might upload a file named in Greek language (I know that he/she shouldn’t) in that case the file will be uploaded but the name will change to something unreadable like:
“20140520082344_ΞΞΞΞΞΞΉΞΊΞ_ΞΟΟΞµΞΞ_ΞΞµ_ΞΊΞµΞΞ_1.jpg” it might look like Greek to you but trust me it isn’t 🙂

How can I change the files name after the time stamp.
example "20140520082344_uploadedfile.jpg"

File: /administrator/components/com_chronoforms5/chronoforms/actions/file_upload/file_upload.php

	//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;
	}
		}
Gatsman 21 May, 2014
Answer
Can't say if this is the best solution but it will change any filename to something like this: 20140521092017_file.jpg

Edit File: administrator/components/com_chronoforms5/chronoforms/actions/file_upload/file_upload.php
//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{
			$parts = explode('.',$file_name);
			$filesuffix = $parts[1];
			$file_name = 'file.'.$filesuffix;
			$file_name = date('YmdHis').'_'.$file_name;
		}
GreyHead 21 May, 2014
Hi Gatsman,

CFv4 has a Websafe Filename option - it looks as though that hasn't made it into CFv5 yet.

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