Search code examples
c#asp.netajaxajaxcontroltoolkit

AjaxFileUpload Button 'Upload' Failure


I have done quite a bit of searching, and tried many different options. Haven't even seen any other person who has been having a similar problem.

I have the the following code placed into my page and the element reacts fine on the page. For the 'ToolKitScriptManager I have tried both the regular as well as the one shown below. Neither work.

        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
        <asp:AjaxFileUpload ID="inpFileUpload" runat="server" OnUploadComplete="inpFileUpload_UploadComplete" MaximumNumberOfFiles="3" AllowedFileTypes="jpg,jpeg,doc,png" />

I have the following background code for the element

    protected void inpFileUpload_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        string path = @"\\NetworkPath\UploadedFiles\" + e.FileName;
        inpFileUpload.SaveAs(path);
    }

However it gives me no error, or message stating anything that could be going wrong. I have followed every tutorial I can find on this element and none have been able to fix this issue.

I press browse to find a file, select one/more than one and everything appears to be doing fine, the files appear in the upload list.

However when I click the 'Upload' button that comes with this AjaxFileUpload element nothing happens. At times you can see red on the Upload button but it immediately goes back to the 'Upload' blue style again. Does not upload the files selected, or from what I can tell it isn't doing anything when the button is pressed other than very quickly changing the look of the button.

Not sure what I am doing wrong, or if I am missing something..

UPDATE

Thanks to the help of Matthew learned there was a javascript error console which when pressing the 'Upload' button it returns "Uncaught Exception: Failed to starting upload"


Solution

  • Looks like I solved it. It has something to do with my Request.QueryString["id"] when I load the page. For some reason it reloads the page and loses that QueryString which returns null which in turn causes everything to mess up for the file upload.

    When I assign a hard coded variable as the QueryString["id"] the upload works fine. However when left normal to get the QueryString it fails and returns null.

    I have not solved out why it is grabbing null and not my id number but me hard coding in the id number and the upload works pretty much confirms that this is the issue.

    If anyone might have information as to why my QueryString returns null on file upload that would be great! haha

    ANSWER

    So did some research, apparently this is a problem with AjaxToolKit and not anything I have been doing. I downloaded the links off https://ajaxcontroltoolkit.codeplex.com/workitem/27149 and used the DLLs with the updated javascript code changes and everything started working fine.

    From what I found the fileupload does not parse for already placed querystrings in the URL so it replaces them with what it needs and continues on with out many errors.

    Lets hope they get an updated version of it out.