Hey,
I wouldnt be too concerned about the users providing an invalid file name. The URL’s to the images are html encoded which should prevent bad links for weird file names. (e.g. double spaces).
I can add the ability to do this, or at least provide you some code that will do it but I need a little more info on what you’re wanting the new file names to be.
For example, using this code here will make the file name be First_###### — which will stop duplicate file names as well.
class tarUploadHandler extends UploadHandler {
protected function trim_file_name($file_path, $name, $size, $type, $error, $index, $content_range) {
$name = 'First_' . microtime(true);
$name = str_replace('.', '', $name);
return $name;
}
}
Im tempted to just add one or two simple options with no other configuration. e.g. ‘make random file names’ and ‘prefix and random file name’.
Hi ovann86,
Basically I want to rename file with field id. Suppose i have 5 ajax fields on same form and I want to rename uploaded files as:
on field-1: FileOfField1.jpg
on field-2: FileOfField2.jpg
on field-3: FileOfField3.jpg
on field-4: FileOfField4.jpg
on field-5: FileOfField5.jpg
it is just I want the respective field id on file name after rename.