R
R
Roman Rakzin2015-09-27 19:36:53
JavaScript
Roman Rakzin, 2015-09-27 19:36:53

How to download a local file not from a web server, but locally?

Good afternoon. I want to make an html application and need to upload a file.
The problem is that it will not be a web server, but simply a set of files on a local computer and phone. For security reasons, the browser cannot read the local file.
The bottom line is that there is an html file and a text file. Here is the text file I need to read.
I include jquery and write

$.ajax({url:"text1.text"}).success(function(data){ alert(data); });

But since It's not the web server that answers, so I don't see anything.
At the same time, if I enter the address of this text file in the browser along the same path as the html file, then it is displayed.

The bottom line is that you just need to read the file.
I don’t use a web server because I want to make a page for my phone, there is no Internet in that area, and I don’t know how to program on android. In general, I want to make a local page.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Timofeev, 2015-09-27
@webinar

Install a local server like OpenServer.
Or use technology that is designed for what you do.

M
MK, 2015-09-27
@Maxsior

you can try using the file:/// protocol,

E
Evgeny Vyushin, 2015-09-28
@e-vyushin

If a local file could be loaded so easily through a browser, jQuery could steal all the files from the user. Browsers block attempts to access local files in standard ways.
The fastest solution I can advise you is to install http-server for node.js and share the required directory
https://www.npmjs.com/package/http-server

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question