0

点击我的下载按钮后,我继续“拒绝访问”。我已经完全控制了指定的文件夹。

我在 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+ ".");
    }
}
4

1 回答 1

3

您无法像在代码段中那样访问本地文件。

您必须将文件上传到服务器并使用 PHP/另一种服务器端语言来执行此操作。jQuery(或 Javascript)仅在浏览器中运行,无法访问浏览器之外的文件。服务器端 Web 语言只能访问位于服务器(或使用 get_file_contents 或 cURL 的其他服务器)上的文件。

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

于 2012-07-13T07:06:41.817 回答