admin管理员组文章数量:1336633
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:
:_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?
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/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?
Share edited Apr 22, 2012 at 18:49 Michael asked Apr 22, 2012 at 18:14 MichaelMichael 9,40215 gold badges73 silver badges137 bronze badges2 Answers
Reset to default 1<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)
- make a new folder inside ur website
2 copy all the data in the new folder
3.then provide the link to that folder.
本文标签: javascriptHow do I view file images from httplocalhost served pages in Firefox 11Stack Overflow
版权声明:本文标题:javascript - How do I view file: images from http:localhost served pages in Firefox 11? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742400394a2467771.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论