Reputation: 1302
I have a web form that will upload a user-selected file. I need to get the icon file that is registered on the user's system for this file to upload it along with the uploaded file. How can I access a local file and extract its associated icon in the browser with JavaScript?
If this can be done, and you know how, thanks in advance.
Upvotes: 2
Views: 2046
Reputation: 35895
In Firefox you can use the moz-icon://
filename
[?size]
URI scheme.
For example: moz-icon://someDocument.pdf?size=32
will display a 32x32 pixel image for whatever image is registered on the user's system for the filename extension.
Upvotes: 0
Reputation: 41050
You can't access local files of the user with JS. This is prevented by the security sandbox model of all browsers explained here http://en.wikipedia.org/wiki/JavaScript#Security and http://en.wikipedia.org/wiki/Same_origin_policy.
But there is a way on Mozilla based browser, set netscape.security.PrivilegeManager.enablePrivilege(”UniversalFileRead”)
in about:config
, see details here: http://cakebaker.wordpress.com/2006/03/29/file-upload-with-selenium/
Upvotes: 6