1

I am new to angularJS ,i want to read a json file from my local system, when i try to read the file it throws a exception Error: Access to restricted URI denied XMLHttpRequest.

My code

var deferred = q.defer();
http.get('file:///C:/configjson.json').success(function(data) {
    angular.extend(this, data);
    deferred.resolve(data);
}).error(function() {
    deferred.reject('could not find File');
});

please help me

CodingIntrigue
  • 75,930
  • 30
  • 170
  • 176
Sachin
  • 497
  • 5
  • 8
  • Here is a solution that uses a library called AngularLoad but takes a little tweaking - http://zacklalanne.com/webapp-over-the-file-protocol-using-angularjs/ – display name Feb 20 '15 at 13:06

1 Answers1

2

You just can't this would mean a big security leak. this would mean you could actually upload any files of some computer to a server.

The only way you can do this is by uploading it trough a file element in html.

HTML5 fileReader does allow you to work with local files,but only trough a file element. So the user select the file themselves

or save the file in local storage instead of on the disc.

Mark Smit
  • 582
  • 4
  • 12