点击下载按钮后,我仍然出现“访问被拒绝”的情况。 我已经完全控制指定的文件夹。
我在 jquery 中使用它。
function DownloadFile(ProductNumber, File)
{
var windowSizeArray = ["width=400,height=400",
"width=500,height=600,scrollbars=yes"];
File = "C:/Documents and Settings/My PC/My Documents/" + File;
if (File != "")
{
var windowName = "popUp";
var windowSize = windowSizeArray[$(this).attr("rel")];
var exist = isExists(File);
if (exist)
{
window.open(File, windowName, windowSize);
}
else
{
ShowAlertMessage("The file for Product no. <a href='" + File + "' target='blank'>" + ProductNumber+ "</a> does not exist.");
}
}
else
{
ShowAlertMessage("No PDF file for Product no: " + ProductNumber+ ".");
}
}
最佳答案
您无法像在代码片段中那样访问本地文件。
您必须将文件上传到服务器并使用 PHP/另一种服务器端语言来执行此操作。 jQuery(或Javascript)仅在浏览器中运行,无法访问浏览器之外的文件。服务器端网络语言只能访问位于服务器(或使用 get_file_contents 或 cURL 的其他服务器)上的文件。
您的代码看起来像 C#/Java 源代码。他们可以访问这些本地文件。
关于javascript - 下载文件: ACCESS DENIED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11465636/