Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery BlueImp how to change filename before upload?

Is it possible to change the filename of the file being uploaded via jquery blueimp?

like image 331
tom_cruz Avatar asked Nov 04 '14 06:11

tom_cruz


2 Answers

require('UploadHandler.php');
class CustomUploadHandler 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;
        }
}

$upload_handler = new CustomUploadHandler();

In your custom file index.php initialize this function of UploadHandler.php

like image 131
Vladimir Salguero Avatar answered Nov 08 '22 05:11

Vladimir Salguero


This can be achieved with only change the trim_file_name() function to the following in the UploadHandler.php file.

protected function trim_file_name(VARIABLES) {
    $name = uniqid();
    return $name;
}

and that's all

like image 4
Saymon Avatar answered Nov 08 '22 07:11

Saymon