We help IT Professionals succeed at work.

access folder out side the virtual path on server in javascript

Saroj13 asked

I have folder having javascript files outside of the virtual path on the server. I dont want to hardcode the url/ or the folder path.

I need to access the folder in <a href..> How this can be done in javascript?

Watch Question

Chinmay PatelChief Technology Ninja
Distinguished Expert 2019

Hi Saroj13,
Unless and until you configure your path to be covered under a virtual directory your end user will never ever be able to access to that path unless and until you are making an intranet portal and your scripts are on a shared folder. If you are making a site that is going to be hosted on a public facing web site than there is no way we can achieve this.


I have web application like test. So Test is my virtual directory. Test application is using some banner fiiles located on the d drive outside the virtual directory. Test application access files using < a href="...
How I can do that.
Chinmay PatelChief Technology Ninja
Distinguished Expert 2019

See if you are developing this application for your own usage then and only it will work, 'cause how other users will access those files which are on your D drive? are you going to host the application?
Fixer of Problems
Most Valuable Expert 2014
If this is an internet application for a web site, it is totally against the security rules for web servers to allow access outside the web root.  You need to move the banner files to be able to use them on a web page.
You cannot access the server folder from javascript.

You need to invoke a servlet or other server side script to do the same.