Source language: Translate to:

read a local file

General questions about NeoAppBuilder - our rapid application development tool for building HTML5, web and mobile apps.

Moderator: Neosoft Support

read a local file

Postby David de Argentina » Wed Sep 30, 2015 3:06 pm

hI all,

My app needs to get some values from a local text file called data.txt.

I had tryed some ways to do. Most relevant are:

a)
Code: Select all
$.get('data.txt', function(data) {
  alert(data);
}, "text");


b)
Code: Select all
var oMyBlob = new Blob(["data.txt"], {type : 'text/html'});
var reader = new FileReader();
  reader.onload = function(){
  var text = reader.result;
  var node = document.getElementById('output');
  node.innerText = text;
  console.log(reader.result.substring(0, 200));
}
reader.readAsText(oMyBlob);


But nothing worked.
a) has a cross-domain problem (no webbrowser at phone -> no possible php file...)
b) returns the filename (data.txt)

Any ideas ?

Thanks in advance,
David de Argentina
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Re: read a local file

Postby Neosoft Support » Wed Sep 30, 2015 6:27 pm

NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: read a local file

Postby David de Argentina » Wed Sep 30, 2015 7:18 pm

Thanks Dave,

Same errors (in both links) :

"XMLHttpRequest cannot load file:///C:/Listener/Filereader/data.txt. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource."

I think i must go for another way.
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Re: read a local file

Postby yanzco » Mon Jan 23, 2017 6:30 am

also exploring in neoappbuilder

anyone know how to save some variables to a txt file?..
and read txt file content to a variable
?
yanzco
 
Posts: 175
Joined: Sun Jul 20, 2014 4:07 am

Re: read a local file

Postby Neosoft Support » Wed Jan 25, 2017 7:20 pm

See the two links above.

Also try NAB's built-in Local Storage actions if you just want a simple method of saving data between sessions.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: read a local file

Postby yanzco » Wed Jan 25, 2017 7:41 pm

i was trying to make an simple app for android..
and want to try saving a txt file to the sdcard.. or some folder in android that is accessible..

read and write, if possible..
yanzco
 
Posts: 175
Joined: Sun Jul 20, 2014 4:07 am


Return to General NeoAppBuilder Discussion

Who is online

Users browsing this forum: No registered users and 1 guest