Load local file error

Avatar

Avatar

davidm87596861

Avatar

davidm87596861

davidm87596861

13-07-2017

I cant load a local file because http is only allowed.

XMLHttpRequest cannot load file:///var/mobile/... Cross origin requests are only supported for HTTP.

How can i allow to load local files in an app? Thanks, David

View Entire Topic

Avatar

Avatar

Bruce_Lefebvre

Employee

Avatar

Bruce_Lefebvre

Employee

Bruce_Lefebvre
Employee

13-07-2017

Hi David,

I've put together a simple example that shows how you can read JSON data from a local file:

GitHub - blefebvre/aemm-read-local-file: Example article that shows how you can read a local file on...

The file being read can be found here: aemm-read-local-file/data.json at master · blefebvre/aemm-read-local-file · GitHub

And the code which is reading it using an XHR is here: aemm-read-local-file/index.js at master · blefebvre/aemm-read-local-file · GitHub

When you run the app via either the aemm CLI or AEM Mobile Preflight, you will see the message from the file is displayed in the app:

Screen Shot 2017-07-13 at 3.32.16 PM.png

Hope this helps.