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() {
var APPLICATION_ID = '',
SECRET_KEY = '',
VERSION = 'v1'; //default application version;
return Backendless.initApp( APPLICATION_ID, SECRET_KEY, VERSION );
};
connectBackendless();
var el = document.getElementById('files');
if(el){
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 );
}
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.
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