Issue with fileupload control RRS feed

  • Question

  • Hi,

    I have fileupload control on a page with style element display has none. I have a Html Image control on the same page, Once after clicking on this image control, a javascript function will invoke and get elementId of fileupload control and perform click Operation on it. Once after clicking it. automatically browse windows is being opened and able to select the file. For file upload control, I have written onchange event, which internally calls a javascript function for previewing the image. In the same page I have a submit button for submitting form details. But the problem here is after clicking submit button I am not able to get the posted file. Always FileUpload.PostedFile value is null.

    Note here every thing is done through javascript at client side

    How to send fileupload value to the server for storing file info on solution folder?



    Wednesday, December 5, 2012 1:32 PM


  • Hi,

    Using the uploadFile control to upload the image and then using image control to display it:

            <asp:FileUpload ID="FileUpload1" runat="server" /> 
            <asp:Button ID="Button1" runat="server" 
                Text="Button" onclick="Button1_Click" /> 
            <br /> 
            <asp:Image ID="Image1" runat="server" /> 
    protected void Button1_Click(object sender, EventArgs e) 
            if (FileUpload1.HasFile) 
                string pathSaved = Server.MapPath("Images"); 
                string fileName = FileUpload1.FileName; 
                string fileName1 = FileUpload1.PostedFile.FileName; 
                string imagePath=pathSaved + "\\" + fileName; 
                Image1.ImageUrl = "Images\\" + fileName; 

    BTW, this is more close to issue, please ask for help from its dedicated forum:

    Your Name
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, December 7, 2012 5:14 AM