1

I'm using jQuery Mobile framework. I'm having a server which hosts a website. The user can connect to website through mobile browser and download files (.doc, .xls, .pdf etc.) from that website. I need to open the file which is saved in the user's mobile programmatically using JavaScript. I tried to open using location.href="file://sdcard/download/test.doc". But it didn't work. It showed permission denied. Is there any way to this? Please help. Thanks in advance.

1
  • any way of doing this would be a security hole and even if you find one - it will be fixed Commented Jan 3, 2011 at 11:51

3 Answers 3

3

For security reasons, browsers will block all access to your local file system. You would have to use other extensions to access those files--or download them to a local variable instead of the file system.

If regular old JavaScript could access your filesystem bad people would be able to do really bad things with greater ease and efficiency. There are a couple of possibilities if you are not using a browser:

http://www.c-point.com/JavaScript/articles/file_access_with_JavaScript.htm http://www.webreference.com/js/column71/

Those articles are fairly platform specific, and do not leverage the best practices for security though. Caveat Emptor

Sign up to request clarification or add additional context in comments.

Comments

2

You can't access the filesystem from pure web-based JavaScript alone, especially not in a cross-platform or cross-browser manner. But you can access the filesystem from ActiveX Controls on Internet Explorer, from Firefox extensions, and from Java applets, all of which you might be able to interact with using JavaScript. Of course you'll have to get the user to install the ActiveX, extension, or applet on the browser first.

Comments

1

There is no way to do this in Javascript. Access to local files is categorically denied for security reasons.

You can link to the file using a <a> element but even that is disabled in most browsers.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.