Questions tagged [local-files]
159 questions
471
votes
26 answers
Loading local JSON file
I'm trying to load a local JSON file but it won't work. Here is my JavaScript code (using jQuery):
var json = $.getJSON("test.json");
var data = eval("(" +json.responseText + ")");
document.write(data["a"]);
The test.json file:
{"a" : "b", "c" :…

Patrick Browne
- 5,290
- 4
- 16
- 14
198
votes
5 answers
How can I create a link to a local file on a locally-run web page?
I'd like to have an html file that organizes certain files scattered throughout my hard drive. For example, I have two files that I would link to:
C:\Programs\sort.mw
C:\Videos\lecture.mp4
The problem is that I'd like the links to function as a…

Brian Fitzpatrick
- 2,443
- 2
- 14
- 14
144
votes
4 answers
Allow Google Chrome to use XMLHttpRequest to load a URL from a local file
When trying to do a HTTP request using XMLHttpRequest from a local file, it basically fails due to Access-Control-Allow-Origin violation.
However, I'm using the local web page myself, so I was wondering if there is any way to make Google Chrome…

pimvdb
- 151,816
- 78
- 307
- 352
141
votes
7 answers
How to fetch data from local JSON file on react native?
How can I store local files such as JSON and then fetch the data from controller?

mrded
- 4,674
- 2
- 34
- 36
53
votes
6 answers
Fetch a file from a local url with Python requests?
I am using Python's requests library in one method of my application. The body of the method looks like this:
def handle_remote_file(url, **kwargs):
response = requests.get(url, ...)
buff = StringIO.StringIO()
…

Ozgur Vatansever
- 49,246
- 17
- 84
- 119
41
votes
6 answers
Setting Cookies using JavaScript in a local html file
I have the following directory tree:
+ folder1
|--- folder2
|------ page1.html
|--- page2.html
If I set some cookie in page1.html using JavaScript, what is the path used for that cookie?
Edit:
Let me explain it better. I'm working with a local…

Oscar Mederos
- 29,016
- 22
- 84
- 124
34
votes
2 answers
Run Greasemonkey on html files located on the local filesystem?
I have an API documentation lying around on my Harddrive and to ease my workflow, I have written a simple script that modifies the page for my needs. I've developed it using FireBug on FireFox.
@include-ing webpages works correctly, but Greasemonkey…

Niklas R
- 16,299
- 28
- 108
- 203
23
votes
9 answers
Check if a file exists locally using JavaScript only
I want to check if a file exists locally, where the HTML file is located. It has to be JavaScript. JavaScript will never be disabled. jQuery is not good but can do.
By the way, I am making a titanium app for Mac so I am looking for a way of…

JqueryToAddNumbers
- 1,063
- 3
- 14
- 28
23
votes
6 answers
Optional appsettings.local.json in (new format) visual studio project
My app uses appsettings.json for some settings. If appsettings.local.json is present, that should override appsettings.json for whatever settings it contains. So far, no problem.
But I use git for version control. Obviously, I don't want other users…

William Jockusch
- 26,513
- 49
- 182
- 323
17
votes
5 answers
Cross-origin request for local file
I need to open a local html file in the browser. The javascript works fine but ajax stops working and XMLHttpRequest gives a cross origin error. Is there a way to run ajax from local directory. It is necessary for me that it is run from local file…

User4870
- 386
- 1
- 4
- 12
16
votes
5 answers
Can I get the history.back() function to work in Chrome when using the file:// protocol?
I'm building an application in an environment where I'm restricted to using the local file system and a browser (i.e. running a server isn't an option). I have a generic 'go back' link on numerous pages that mainly just calls history.back(). It…

Horatio Alderaan
- 3,264
- 2
- 24
- 30
12
votes
4 answers
How do I make a local HTML page auto-refresh on file change?
I view local HTML files in my default browser via the file:// protocol.
I would like to add some code/script to the HTML file, so that on change of the file (and ideally on change of the sucked-in CSS files) the browser refreshes the page.
I tried…

halloleo
- 9,216
- 13
- 64
- 122
12
votes
1 answer
How to open a local file with Javascript FileReader()
I would like to modify this code so that it works with a specific file only, but I can't figure out the correct URL parameter and all the code examples that I've found use a file selection dialog.
reading…

Nemo XXX
- 644
- 2
- 14
- 35
12
votes
2 answers
Using Jquery to get JSON objects from local file
I'm trying to get a list of JSON objects (products) from a local file using Jquery and store all the objects in a single array called allItems. The file is co-located in the same directory as the code, and it's called "allItems.json". Here's how…

ThoughtCrhyme
- 517
- 3
- 8
- 18
11
votes
2 answers
How to import/export hbase data via hdfs (hadoop commands)
I have saved my crawled data by nutch in Hbase whose file system is hdfs. Then I copied my data (One table of hbase) from hdfs directly to some local directory by command
hadoop fs -CopyToLocal /hbase/input ~/Documents/output
After that, I copied…

Hafiz Muhammad Shafiq
- 8,168
- 12
- 63
- 121