SyntaxError
SyntaxError

Reputation: 3859

Download file: ACCESS DENIED

I keep on having "ACCESS DENIED" after hitting my download button. I already have full control on the specified folder.

I use this in 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+ ".");
    }
}

Upvotes: 0

Views: 1495

Answers (1)

OptimusCrime
OptimusCrime

Reputation: 14863

You can't access local files like you do in your snippet.

You have to upload the file to the server and use PHP/another serverside language to do that. jQuery (or Javascript) only runs in the browser and does not have access to files outside it. Serverside web-languages only have access to files located on the server (or other servers using get_file_contents or cURL).

Your code looks like a C#/Java-source. They can access these local files.

Upvotes: 3

Related Questions