下载文件:ACCESS DENIED

Download file: ACCESS DENIED

本文关键字:DENIED ACCESS 文件 下载      更新时间:2023-09-26

点击下载按钮后,我一直保持"访问被拒绝"状态。我已经完全控制了指定的文件夹。

我在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)仅在浏览器中运行,无法访问外部文件。服务器端web语言只能访问服务器上的文件(或使用get_file_contents或cURL的其他服务器)。

您的代码看起来像一个C#/Java源代码。他们可以访问这些本地文件。