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…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/javascript" class="post-tag grid--cell" title="show questions tagged 'javascript'" rel="tag">javascript</a> <a href="../../questions/tagged/filereader" class="post-tag grid--cell" title="show questions tagged 'filereader'" rel="tag">filereader</a> <a href="../../questions/tagged/local-files" class="post-tag grid--cell" title="show questions tagged 'local-files'" rel="tag">local-files</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 02 '15 at 12:35">asked Jun 02 '15 at 12:35</time> <a href="../../users/2614117/nemo-xxx" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/2614117.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Nemo XXX" /> </a> <div class="s-user-card--info"> <a href="../../users/2614117/nemo-xxx" class="s-user-card--link">Nemo XXX</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">644</li> <li class="s-award-bling s-award-bling__gold" title="2 gold badges">2</li> <li class="s-award-bling s-award-bling__silver" title="14 silver badges">14</li> <li class="s-award-bling s-award-bling__bronze" title="35 bronze badges">35</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-2792423"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>12</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/2792423/using-jquery-to-get-json-objects-from-local-file" class="question-hyperlink">Using Jquery to get JSON objects from local file</a></h3> <div class="excerpt">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…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/javascript" class="post-tag grid--cell" title="show questions tagged 'javascript'" rel="tag">javascript</a> <a href="../../questions/tagged/jquery" class="post-tag grid--cell" title="show questions tagged 'jquery'" rel="tag">jquery</a> <a href="../../questions/tagged/json" class="post-tag grid--cell" title="show questions tagged 'json'" rel="tag">json</a> <a href="../../questions/tagged/local-files" class="post-tag grid--cell" title="show questions tagged 'local-files'" rel="tag">local-files</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked May 08 '10 at 00:27">asked May 08 '10 at 00:27</time> <a href="../../users/324675/thoughtcrhyme" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/324675.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="ThoughtCrhyme" /> </a> <div class="s-user-card--info"> <a href="../../users/324675/thoughtcrhyme" class="s-user-card--link">ThoughtCrhyme</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">517</li> <li class="s-award-bling s-award-bling__gold" title="3 gold badges">3</li> <li class="s-award-bling s-award-bling__silver" title="8 silver badges">8</li> <li class="s-award-bling s-award-bling__bronze" title="18 bronze badges">18</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-25909132"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>11</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/25909132/how-to-import-export-hbase-data-via-hdfs-hadoop-commands" class="question-hyperlink">How to import/export hbase data via hdfs (hadoop commands)</a></h3> <div class="excerpt">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…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/hadoop" class="post-tag grid--cell" title="show questions tagged 'hadoop'" rel="tag">hadoop</a> <a href="../../questions/tagged/hbase" class="post-tag grid--cell" title="show questions tagged 'hbase'" rel="tag">hbase</a> <a href="../../questions/tagged/local-files" class="post-tag grid--cell" title="show questions tagged 'local-files'" rel="tag">local-files</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Sep 18 '14 at 09:35">asked Sep 18 '14 at 09:35</time> <a href="../../users/2265190/hafiz-muhammad-shafiq" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/2265190.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Hafiz Muhammad Shafiq" /> </a> <div class="s-user-card--info"> <a href="../../users/2265190/hafiz-muhammad-shafiq" class="s-user-card--link">Hafiz Muhammad Shafiq</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">8,168</li> <li class="s-award-bling s-award-bling__gold" title="12 gold badges">12</li> <li class="s-award-bling s-award-bling__silver" title="63 silver badges">63</li> <li class="s-award-bling s-award-bling__bronze" title="121 bronze badges">121</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <div class="s-pagination--item is-selected">1</div> <a class="s-pagination--item" href="../../questions/tagged/local-files_page=2" rel="" title="Go to page 2">2</a> <a class="s-pagination--item" href="../../questions/tagged/local-files_page=3" rel="" title="Go to page 3">3</a> <div class="s-pagination--item s-pagination--item__clear">…</div> <a class="s-pagination--item" href="../../questions/tagged/local-files_page=10" rel="" title="Go to page 10">10</a> <a class="s-pagination--item" href="../../questions/tagged/local-files_page=11" rel="" title="Go to page 11">11</a> <a class="s-pagination--item" href="../../questions/tagged/local-files_page=2" rel="next" title="Go to page 2"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>