Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When i save json file in web apps then using http://localhost:8080/WGSClient/js/object.json this path file gets open.

But when i keep it outside web apps like local folder then using same url format json file is not accessible.

It showing error that OpenLayers doesn't support this url format.

So what is the proper url which OpenLayers support or i should keep my json file in web apps?

What would be the URL of a JSON file on the local drive?

share|improve this question
Do you mean file:// style URLS? – Matthew Snape Oct 10 '12 at 14:59
localhost/localpath type URL – user9125 Oct 11 '12 at 6:48

Do you mean file URIs? You can try the following format


For example, if you want the file fstab at /etc/


You can also omit the host but don't omit the slash


I hope that helps.

share|improve this answer
file://localhost/etc/fstab using this URI error occurs.Access to restricted URI denied.but when i keep it in web apps then using localhost/path it runs successfully – user9125 Oct 11 '12 at 6:45
Using file://localhost/etc/fstab URI code shows error that 'access to restricted URI denied'..I think openlayers doesn't supports this type of URI.May be it supports localhost type of URL – user9125 Oct 11 '12 at 6:53
Can you try it for other files? fstab is a system file. What about files in your home folder? – R.K. Oct 11 '12 at 7:50
file://localhost/my file path. not successfully running.same error as access denied for restricted url – user9125 Oct 11 '12 at 9:00
Browser support for these type of URLs is patchy for security reasons. Chrome especially will reject localhost and file://. Use an actual web server with real domains. It is not difficult to setup and will be better. – Matthew Snape Oct 11 '12 at 9:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.