For your question "Need Access to Local Text File via JavaScript" is very similar to this question here: Local file access with javascript
The Answer is there really isn't a good way to access a local file if you are using javascript in a browser. If its just a text file on the same machine without a http/webserver you may run into some problems, as in javascript the ability to read a local file is disabled by default in most browsers. In chrome you can disable this security-feature by adding the following flag when starting the browser from command-line.
--disable-web-security
If your data is structured json, xml, csv, you can bring it in using an AJAX call if the file is hosted on a server accessible with HTTP. Without using an http ajax call, another possible solution as mentioned in the question link above:
Just an update of the HTML5 features http://www.html5rocks.com/en/tutorials/file/dndfiles/
This excellent article will explain en detail the local file access in
Javascript. Summary from the mentioned article:
The spec provides several interfaces for accessing files from a
'local' filesystem:
File - an individual file; provides readonly information such as name,
file size, mimetype, and a reference to the file handle. FileList - an
array-like sequence of File objects. (Think or dragging a directory of files from the desktop). Blob -
Allows for slicing a file into byte ranges.
-- @Horst Walter
As shown below you can have a "file upload" input selection, and simply have your file path as a default option for the input"
<input type="file" id="files" name="files[]" multiple />
<output id="list"></output>
<script>
function handleFileSelect(evt) {
var files = evt.target.files; // FileList object
// files is a FileList of File objects. List some properties.
var output = [];
for (var i = 0, f; f = files[i]; i++) {
output.push('<li><strong>', escape(f.name), '</strong> (', f.type || 'n/a', ') - ',
f.size, ' bytes, last modified: ',
f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a',
'</li>');
}
document.getElementById('list').innerHTML = '<ul>' + output.join('') + '</ul>';
}
document.getElementById('files').addEventListener('change', handleFileSelect, false);
</script>