为什么我不能这样做< img src =" C:/localfile.jpg"&gt ;? [英] Why can't I do <img src="C:/localfile.jpg">?

查看:174
本文介绍了为什么我不能这样做< img src =" C:/localfile.jpg"&gt ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果html文件是本地的(在我的C驱动器上),但是如果html文件在服务器上并且图像文件是本地的,那么它就可以工作。为什么会这样?



任何可能的解决方法?

解决方案

如果客户端可以请求本地文件系统文件,然后使用JavaScript来找出它们中的内容,那么就是一个安全漏洞。



唯一的解决办法是在一个浏览器。 Firefox扩展和IE扩展可以访问本地资源。 Chrome的限制更多。


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?

解决方案

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.

这篇关于为什么我不能这样做< img src =" C:/localfile.jpg"&gt ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆