5

我通过从我的站点下载的 html 使用 jQuery ajax 获取本地 xml 文件。

问题是每次下载文件时,用户都必须右键单击它-> 属性-> 取消阻止。否则 jquery ajax 会抛出“权限被拒绝”错误。

有没有办法将文件标记为受信任或类似的东西?下载文件时我应该在服务器端实现一些东西吗?或者在保存的 html 文件中在客户端添加一些东西?提前致谢。

4

3 回答 3

6

NTFS 文件系统将此文件附加到一个不安全的标志。您可以使用 Sysinternals 中的一个名为 Streams 的实用程序来删除此标志。您可以从以下位置下载 Streams:

http://technet.microsoft.com/en-us/sysinternals/bb897440.aspx

然后使用Process 类,您可以在获得文件后运行streams -d <file.xml>命令删除此标志。如何运行它:

Process runcommd = new Process();

runcommd.StartInfo.FileName = "streams";
runcommd.StartInfo.Arguments = " -d \"fullpath\\file.xml\"";

runcommd.StartInfo.UseShellExecute = false;
runcommd.StartInfo.CreateNoWindow = false;

runcommd.StartInfo.RedirectStandardError = true;
runcommd.StartInfo.RedirectStandardOutput = true;
runcommd.StartInfo.RedirectStandardInput = true;

// now run it
runcommd.Start();

// be sure that we end
runcommd.StandardInput.Flush();
runcommd.StandardInput.Close();

Streams 来自 MS 站点,因此它的官方和可信来源,它只是一个从文件中删除此标志的实用程序。我认为你可以完成你的工作。

相关: https ://superuser.com/questions/38476/this-file-came-from-another-computer-how-can-i-unblock-all-the-files-in-a

http://www.k9ivb.net/files/This%20file%20came%20from%20another%20computer%20and%20might%20be%20blocked.pdf

于 2012-05-14T13:25:10.423 回答
1

@Aristos 在备用文件流问题上很准确,但是这可以在不使用外部 EXE (streams.exe) 的情况下完成。对于稍后查看此内容的其他人,您可以运行以下命令来清空备用文件流 (AFS):

echo. > my_blocked_file.zip:Zone.Identifier

假设文件名为 my_blocked_file.zip,这将清空 AFS 的内容。此外,您可以发布dir /r列出 AFS 并notepad my_blocked_file.zip:Zone.Identifier实际编辑它们。

这是 Internet 区域标识符的样子:

[ZoneTransfer] 
ZoneId=3

这些流的附加阅读:http: //msdn.microsoft.com/en-us/library/ff469212 (v=prot.10 )

各自的安全区域是:

  • 内网:ZoneId=1
  • 可信站点:ZoneId=2
  • 互联网:ZoneId=3
  • 受限站点:ZoneId=4

此外,IE 似乎只在您打开/关闭会话时读取 AFS,因此您无法更改流然后刷新,您需要创建一个新的 IE 实例来重新读取新的 AFS。

于 2012-05-15T22:48:00.487 回答
0

试试这个。打开 regedit,然后查找以下键/值:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments\SaveZoneInformation

将此值设置为 1 并查看问题是否仍然存在。可能必须注销并重新登录才能确定,因为它是 HKCU 值。您仍然可能会再次收到此消息,但如果您使用此值再次取消阻止它,它可能会阻止它再次发生。

于 2012-05-14T11:34:58.060 回答