点击下载按钮后,我继续“拒绝访问”。 我已经完全控制了指定的文件夹。
我在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+ ".");
}
}
答案 0 :(得分:3)
您无法像在代码段中那样访问本地文件。
您必须将文件上传到服务器并使用PHP /其他服务器端语言来执行此操作。 jQuery(或Javascript)仅在浏览器中运行,并且无法访问其外部的文件。 Serverside网络语言只能访问位于服务器(或使用get_file_contents或cURL的其他服务器)上的文件。
您的代码看起来像C#/ Java源代码。他们可以访问这些本地文件。