Why can't I do <img src="C:/localfile.jpg">?

PeterV picture PeterV · Nov 3, 2010 · Viewed 318.3k times · Source

It works if the html file is local (on my C drive), but not if the html file is on a server and the image file is local. Why is that?

Any possible workarounds?

Answer

Bjorn picture Bjorn · Nov 3, 2010

It would be a security vulnerability if the client could request local file system files and then use JavaScript to figure out what's in them.

The only way around this is to build an extension in a browser. Firefox extensions and IE extensions can access local resources. Chrome is much more restrictive.