Backendless.Files.upload( files, '/myFiles') don't work with IE Browser

Hi,

I have tried Backendless.Files.upload( files, ‘/myFiles’) (in async and sync) with IE Browser but I have an error :
“Unable to get property ‘fileURL’ of undefined or null reference”

Do you have a solution for this please ?
I think fileURL is not recognized with IE no ?

Thank you for your help

Hi AurelieGl,

Please, provide us the code examples to reproduce your problem.
Also, are you sure that the problem is in IE? Did you try to run your code in other browsers (Chrome, FireFox)?

Regards, Ilya

Hi, thank you for your response

Yes I’m sure because I don’t have errors with FF and Chrome.
And I use your example in javascript and async here : https://backendless.com/feature-31-uploading-files-to-server-with-the-file-upload-api/

My code :

function handleFileSelect(evt,lig){
  files= evt; //type file
  //console.log(files);

function successCallBack(file){
  console(3);
  console.log(file);
  var length = file.fileURL.length;
  var f2 = file.fileURL.substring(74, length);
  var strfilename = file.fileURL.substring(83, length-4);
  console.log("lig : "+lig);
  if(strfilename!=lig){
    Backendless.Files.remove( "/Files/"+lig+".png")
    Backendless.Files.renameFile( f2, lig+".png" );
  }
}

function errorCallback(e){
  console.log(e.message);
}

console(1);
var async = new Backendless.Async(successCallBack,errorCallback);
console(2);
Backendless.Files.upload(files,'/Files',true,async);
}


The first problem with this solution : the line 23 don’t call successCallBack (this function is not executed).
I suppose IE interprets this, like a variable
Result of log : 1 - 2 displayed, but no 3

If I write successCallBack like a function (just for IE) like :

var async = new Backendless.Async(successCallBack(files),errorCallback(files)); //I know it's bad ^^

Result of log : 1 - 3 displayed, no 2

In conclusion, I have this error because the 2 is not executed.
But the ‘file’ variable is not undefined.

I have tried the sync solution too with IE.

 var uploadedFile = Backendless.Files.upload( files, '/myFiles'); 
 console.log( "Uploaded file URL - " + uploadedFile.fileURL); 

The console.log displays the error present in the file 2.png (attached in the first post).

Probably, the first problem create the second problem.
I don’t know how do I write the line 22 for IE.
With FF and Chrome it’s perfect.
Thank you for your help

Hi,

try to change in the second line

files= evt; //type file

to

files = evt.target.files;

You should take files from file select, not it’s event.

And what lig argument means? As far as I know there are no second argument when you click on file select.
If you want to take a file name of uploaded file, you can do it next way before upload:

files = evt.target.files;
var fileName = files[0].name

Hope it helps.

Regards,
Stanislaw

Hi Stanislaw,

If I write like you, I have this error (see evttargetfiles.png): Unable to get property ‘files’ of undefined or null reference
.
‘lig’ is just a filter for others treatments (exemple the word ‘gift’ to execute others functions ).
.
Why does evt contains file argument?
I have a dropzone for one file and when this zone is modified, the dropzone object calls (in onselect :slight_smile: the handleFileSelect function. (see in obj.png)
I don’t have a list of files. I work just with the event containing one file (it’s the event returned).

In file.png you can see the file object, and we don’t have the fileURL attribut (because it’s not a filelist if I understand)
So Backendless.Files.upload don’t work if it’s not a list of files ? So strange, we have no problem with Chrome and FF

obj.png

I have tried this simple request with a file object in evt.

This exemple work with Chrome and FF, but no with IE.
The difference with IE is : this line is not interpreted like Chrome and FF :

 var async = new Backendless.Async(successCallback, errorCallback); 

successCallback and errorCallback are not executed

I’ve found a problem. IE does not support readAsBinaryString method in FileReader instance.

I had created an internal ticket for this problem and hope will release new version of JS SDK with this fix today or little bit later. I’ll notify you here once it’ll be resolved.

Regards,
Stanislaw

Thank you Stanislaw for your response and the research.
Let me know when it will be ok :slight_smile: