shabbir.rang
shabbir.rang

Reputation: 279

How to access files which are stored outside project in javascript?

I am trying to display files from the local directory using javascript. Is this possible? As earlier i used the files which were inside the project using this format : Url : './files/'. Worked pretty well with javascript. Now i want to access files from outside the project eg. Url : "d:/" But javascript has some restrictions on that. How can i load files from d: drive using javascript?

$(document).ready(function(){
URL = 'd:/content/abc.pdf'; /// ??????
});

Upvotes: 0

Views: 180

Answers (2)

Viktor S.
Viktor S.

Reputation: 12815

You can't load files from local computer with JavaScript. Otherwise any website would be able to steal info from user. The only way is to ask a user to upload a file (maybe with ajax) and take it from your server than.

Upvotes: 0

user149341
user149341

Reputation:

No, this is not possible. When running in the context of a web page, Javascript cannot read files which are not available on the web.

Upvotes: 4

Related Questions