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?


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.

| 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
  • 1
    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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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