如何查看来自Firefox 11中http:// localhost服务页面的file://图像? [英] How do I view file:// images from http://localhost served pages in Firefox 11?

查看:236
本文介绍了如何查看来自Firefox 11中http:// localhost服务页面的file://图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的本​​地主机(端口8080)上正在尝试为本地文件创建IMG标记。但是,这些文件并没有出现在Firefox 11中。



我最初使用Javascript创建了图片标签,但是因为失败了,我又回到了HTML,尝试了各种方法直接引用该文件。以下任何一项工作:

 < img src =file:/// localhost:8080 / C:// Users /me/IMG_1000.JPG\"> 
< img src =file:/// localhost / C://Users/me//IMG_1000.JPG>
< img src =file:/// C://Users/me/IMG_1000.JPG>

如果我将最后一个网址直接粘贴到地址栏中,图片就会打开。



我已经按照这里的指示:

http://kb.mozillazine.org/Firefox_:_Issues_:_Links_to_Local_Pages_Don%27t_Work



我有尝试直接通过about:config查看器修改user.js和prefs.js。



从帮助 - >疑难解答信息 - >配置文件目录 - >打开包含文件夹,我找到了正确的路径。 $ b

添加的相关行是:
$ b $ pre $ user_pref(capability.policy.localfilelinks.checkloaduri.enabled,所有的出入口);
user_pref(capability.policy.localfilelinks.sites,localhost:8080);
user_pref(capability.policy.policynames,localfilelinks);

我最初把http://放在localhost:8080中,但Firefox删除了它。我也尝试过只是http:// localhost和http://127.0.0.1,但那些也没有工作。



但奇怪的是,即使我从about:config输入它们,并可以在prefs.js中看到它们,但我无法从about:config中看到它们。这让我想,也许在Mozilla的信息已经过时,毕竟它说的信息是Firefox 1.5及以上,我使用Firefox 11!

注意:我想使用file:// access的原因是我不想允许任意访问我的机器上的文件。为了解释更多:我有一个数据库的接口,并且访问数据库所需的全部内容都是一个密码。这很好,因为我想允许数据库访问我的机器以外的任何人与密码,但图像文件存在数据库之外。为了服务器通过服务器上的文件(因为存在的文件是动态的),我需要创建一个新的CGI,在数据库中采取某种标识符,但由于用户可以访问数据库,他们可以注入任何文件名他们想要的。

编辑:另外,我也不能window.open()文件的URL。有什么可能的安全利益呢?

解决方案

 < img src =file: ///localhost:8080/C://Users/me/IMG_1000.JPG\"> 
< img src =file:/// localhost / C://Users/me//IMG_1000.JPG>

如果它是8080上的服务器,则不应该使用file:// - 不是一份文件。它应该是 http:// localhost:8080 / blah 。我不认为这样做,但第二个(如果它应该工作)将是文件:/ /本地主机/ C:/ * - 注意斜杠的数量。而上面的行有一个额外的/ /它应该是/

 < img src =file:/// C ://Users/me/IMG_1000.JPG> 

现在有道理,但是由于安全限制。

$ $ $ $ $ $ $ $ user_pref(capability.policy.localfilelinks.sites,localhost:8080);

如果页面(可能)应该工作在文件:/// c:/ *从 http:// localhost:8080 / *加载。




  • 使用 http:// localhost:8080 / * - 可能是最好的解决方案 li>
  • 使用一个文件夹,并将其全部设置为实际文件的软链接或硬链接,以最大限度地降低磁盘使用率和更新问题。 使用文件夹并使用任何一个文件夹进行同步无数的工具(rsync等)


I've got a server running on my localhost machine (port 8080) that is trying to create IMG tags to local files. But, the files do not appear in Firefox 11.

I was originally create the image tag using Javascript, but since that failed I fell back to HTML to experiment with various ways of directly referencing the file. None of the following work:

<img src="file:///localhost:8080/C://Users/me/IMG_1000.JPG">
<img src="file:///localhost/C://Users/me//IMG_1000.JPG">
<img src="file:///C://Users/me/IMG_1000.JPG">

If I paste the last URL directly into the address bar, the image opens fine.

I have followed the directions here:

http://kb.mozillazine.org/Firefox_:_Issues_:_Links_to_Local_Pages_Don%27t_Work

I have tried modifying both user.js, and prefs.js, both directly and via the about:config viewer.

I got the correct path to the profile directory from Help -> Troubleshooting Information -> Profile Directory -> Open Containing Folder.

The relevant lines added are:

user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess");
user_pref("capability.policy.localfilelinks.sites", "localhost:8080");
user_pref("capability.policy.policynames", "localfilelinks");

I originally put http:// in from of "localhost:8080", but Firefox removed that. I also tried just "http://localhost" and "http://127.0.0.1", but those did not work either.

BUT... strangely enough, even though I entered them from about:config and can see them in prefs.js, I cannot see them from about:config! This makes me think that perhaps the information at mozillazine is out of date, after all it says the info is for "Firefox 1.5 and above" and I am using Firefox 11!

Note: the reason I want to use file:// access is that I don't want to allow arbitrary access to the files on my machine. To explain a bit more: I've got an interface to a database, and all that is required to access the database is a password. That's fine because I want to allow database access outside my machine to anyone with the password, but the image files exist outside the database. In order to server up the files through the server (because the files that exist are dynamic) I would need to create a new CGI that takes some kind of identifier in the database, but since the user can access the DB they could inject any filename they wanted.

Edit: Also, I can't window.open() the file URL either. What possible security benefit could that have?

解决方案

<img src="file:///localhost:8080/C://Users/me/IMG_1000.JPG">
<img src="file:///localhost/C://Users/me//IMG_1000.JPG">

If it's a server on 8080, you shouldn't be using file:// -- It's not a file. It should be http://localhost:8080/blah. I don't think it works this way, but the second (if it should work) would be file://localhost/c:/* - note the number of slashes. And the line above has an additional // where it should be /

<img src="file:///C://Users/me/IMG_1000.JPG">

Now that makes sense, though for that you'll be limited in the ability to access it because of the security restrictions.

user_pref("capability.policy.localfilelinks.sites", "localhost:8080");

That (probably) should work the the file:///c:/* stuff if the page is loaded from http://localhost:8080/*.

  • use http://localhost:8080/* - probably the best solution
  • Use a folder and make it all soft or hardlinks to the actual files to minimize disk usage and update issues.
  • Use a folder and synchronize using any one of a myriad of tools (rsync, etc)

这篇关于如何查看来自Firefox 11中http:// localhost服务页面的file://图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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