I currently have an ASP.NET MVC project that is using BlueImp jQuery FileUploader which works great.
https://github.com/blueimp/jQuery-File-Upload
However, it appears that the default behaviour is to use the original filenames when uploading files to the server. Ideally, what I would like is to have the jQuery FileUploader generate a unique filename for each file uploaded.
I did try performing a rename of each uploaded file on the server, but I then realised that the FileUploader seems to hang on to the original filenames.
Is there a way of making the jQuery uploader generate a random/unique filename for each image uploaded (whether that be individually or as a batch)?
I just had the same issue. Using the upload.class file for PHP I added a unique file name to the handle_file_upload method like so:
before:
$file->name = $this->trim_file_name($name, $type, $index);
after:
$file->name = $this->trim_file_name(md5($name), $type, $index);
I'm sure you can do something similar in ASP.NET
EDIT:
In the latest version it is on line 506 in UploadHandler.php, change:
$name = $this->trim_file_name($file_path, $name, $size, $type, $error, $index, $content_range);
To
$name = $this->trim_file_name($file_path, md5($name), $size, $type, $error, $index, $content_range);
Works perfect!
protected function handle_file_upload($uploaded_file, $name, $size, $type, $error,
$index = null, $content_range = null) {
$file = new stdClass();
}
before:
$file->name = $this->get_file_name($name, $type, $index, $content_range);
after:
$file->name = $this->get_file_name(uniqid(), $type, $index, $content_range);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With