FileUploader.js(Dojo Widget) is not working in mobile but working fine in MobileFirst Console

145 views Asked by At

Hi I have tried Integrating FileUploader.js (DOJO WIDGET) to my sample project in order to Attach and Upload the file contents from local memory

Get the file from sdcard/internal memory and i want show that file in mobile device

  • Worked fine in IBM MobileFirst console( I was able to upload the file with out any problem
  • When tested in mobile it's not working.

  • This is where the location of FileUploader.js is in my Project Explorer:

/dojoLib/toolkit/dojo/dojox/form/FileUploader.js

Please suggest.

JS code

require(['dojox/form/Uploader', 'dojox/form/uploader/plugins/Flash'], function(Uploader){
  myUploader = new dojox.form.Uploader();
});

function dojoInit() {
 require([ "dojo/ready", "dojo/parser", "dojox/mobile", "dojo/dom", "dijit/registry", "dojox/mobile/ScrollableView", "dojo/data/ItemFileReadStore", "dojo/data/ItemFileWriteStore", "dojox/mobile/SearchBox", "dojox/form/Uploader"], function(ready) {
  ready(function() {
  });
 });
}

[html code--][1]

<div data-dojo-type="dojox.mobile.ScrollableView" id="view0" data-dojo-props="selected:true">
      
  <form method="post" action="UploadFile.php" id="myForm" enctype="multipart/form-data" >
      <input name="uploadedfile" multiple="true" type="file" data-dojo-type="dojox.form.Uploader" label="Select Some Files" id="uploader" />
      <input type="submit" label="Submit" data-dojo-type="dijit.form.Button" />
  </form>

   </div>

Android in in app/res/xml/config.xml already have plugin

Android in app/AndroidManifest.xml already have plugin

1

There are 1 answers

4
Idan Adar On

Suggestions:

  • mention the MobileFirst version you are working with
  • provide actual code

Here's why it is failing for you... When you test in a desktop browser, you are not in a mobile app. You are in a desktop browser. In a desktop browser in your PC you have access to the local filesystem and that's why the widget worked for you.

But when you are in a mobile device, you do not have access to the file system. You must request this access. To do so, you must use the Cordova FileSystem API. Please refer to that and implement accordingly based on their examples: https://cordova.apache.org/docs/en/3.0.0/cordova/file/file.html