'How to change a filename when uploading with blueimp jQuery-File-Upload?

Here is my problem.
I am trying to create a programmatic way (without the customer to input anything) for a customer to fill some web forms. For this, I have created a custom browser (which will be installed in customer's machine as a java application, using eclipse swt with xulrunner v10.0 support).
One of these forms requires to upload a file using the blueimp jquery fileupload plugin. This file is hosted at customer's machine at a predefined directory (let's say C:\ as it's a windows-only based application).

I have used the following snippets:

Create file using javascript hosted at customer's local machine:

var myFile = File("C:\some_dummy_file");

and upload the file programmatically:

$('#some_form').fileupload('add', {files: myFile});

Everything is working just fine, with one exception:
The uploaded file has now name 'C:some_dummy_file' (and not 'some_dummy_file') as it seems to include the directory that it resides. Unfortunately as the server applies file name validation, it rejects the upload as it expects only files with name 'some_dummy_file'.
Additionally, as I don't have control at server side, I cannot change the file name at server side (I have seen some examples for these cases but these cannot be used in my case).
What are my available options / workarounds? Is there any way to change the name before adding (or submitting) the file?
Of course the way that I am creating the file ( var myFile = File("C:\some_dummy_file");) is just a suggestion, so any other suggestions that will resolve my problem are more than welcome.

Thank you very much in advance



Solution 1:[1]

The best for this is to make your images' names unique random(approx.) , for example, like this, using guid:

var myFile = File(guid);
function guid() {

  function s4() {
    return Math.floor((1 + Math.random()) * 0x10000)
      .toString(16)
      .substring(1);
  }
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
    s4() + '-' + s4() + s4() + s4();
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 alexey