Why image cannot be uploaded via mobile using javascript

Hi all,
May I know why the following codes is only able to upload image to backendless on the browser version. However, I am unable to upload image via mobile phone application. I am currently using phonegap to test the code.
Below is the Javascript Code:

function connectBackendless() {
VERSION = 'v1'; //default application version;

return Backendless.initApp( APPLICATION_ID, SECRET_KEY, VERSION );


var el = document.getElementById('files');
 el.addEventListener('change', handleFileSelect, false);

function handleFileSelect(evt) 
 files = evt.target.files; // FileList object
function uploadFileFunc()
 var callback = {};
 alert("in upload file");
 callback.success = function(result)
 alert( "File successfully uploaded. Path to download: " + result.fileURL );
 callback.fault = function(result)
 alert( "error - " + result.message );
 Backendless.Files.upload( files, "my-folder", callback ); 

Please, provide more information.
In what point you are getting error? Have you had something similar to stacktrace ?


When we run the above codes on the browser version, the image was successfully uploaded to Backendless.

However, when we run the same codes on phonegap, the image does not get uploaded to backendless. We are able to see an alert (“is in upload file”) -line 25.

The function is run from a button onclick function.

function uploadFileFunc()

Hi, I am also experiencing this issue. May I know what is the issue with the codes?


Hi Ethan Winters

According to Backendless Docs you missed “overwrite” (3rd) argument,
instead it you passed “callback” as 3rd argument and this is reason why you get no callback

Btw, I’ve setup PhoneGap locally and create a simple “Hello World” app, and try to upload file from WebBrowser and from iPhone and everything works as expected

So, try to add all arguments:

Backendless.Files.upload( files, path, overwrite, async )


Please let us know if it helped you

Regards, Vlad

Yes! It works now! Thank you Mr Vladimir Upirov :slight_smile: