I\'m using the Blueimp jQuery file upload tool. I\'d like to completely rename the files as they\'re uploaded. Since photos are being added to a unique directory based on the us
get_file_name
method is where the actual naming occurs.
In order to avoid much workarounds and just hit the nail on the head, edit it as follows:
protected function get_file_name($file_path, $name, $size, $type, $error,
$index, $content_range) {
$name = $this->trim_file_name($file_path, $name, $size, $type, $error,
$index, $content_range);
//don't return this right away; parse it to a variable
$unique_file_name = $this->get_unique_filename(
$file_path,
$this->fix_file_extension($file_path, $name, $size, $type, $error,
$index, $content_range),
$size,
$type,
$error,
$index,
$content_range
);
//generate your custom name here
$custom_name = uniqid('profilepic');
//extract file extension
$file_extension = pathinfo($unique_file_name, PATHINFO_EXTENSION);
return $custom_name.'.'.$file_extension;
}