开发者

Ie 8.0 Access Denied When Trying To Open Local Files

This script works in IE 6 but not in IE 8.0 My users now get an "Access Denied error". What settings do I refer my users to do enable local file access so that this script will work?

<script language="JavaScript">
function viewFile(selectedItem) {
 for (i=0; i<selectedItem.options.length; i++) {
  if ((selectedItem.options[i] != null开发者_运维问答) && (selectedItem.options[i].selected == true)) {
   window.open("file://"+selectedItem.options[i].text);
  }
 }
}
</script>

Users can select multiple files from local drive. The list is stored in a text box and then clicks on one selected file from the list.

Example:

selectedItem.options[i].text = C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Sunset.jpg


You're not going to be able to do that "out of the box" anymore as IE8's security model is much stricter than IE6.

Your options are limited, but can include:

  1. developing a flash component to access the user's local drive.

  2. Implement the site as an HTA (html application) which gives promoted access to the user's file system.

  3. Have the visitors customize their IE security settings by adding your site to the list of trusted domains and then give trusted domains access to the file:/// protocol (I'm not sure which security setting applies to this particular feature, or if one is even available.)

  4. Develop a pluggin or bho object (similar to flash component, but written in C++ or C#)

  5. Create an IE Context Menu - http://msdn.microsoft.com/en-us/library/bb735853(v=vs.85).aspx which will also have elevated privileges.

As a side note proper file schemes for c:\ paths should look like this:

file:///c:/documents%20and%20settings/file.jpg

Notice the three / after file:, uri-escaped spaces, and all \ are switched to /

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜