0

I have a modal popup and in the modal-body I have two asp.net controls FileUpload control and LinkButton and the markup is

<div class="modal-body">    
    <asp:FileUpload runat="server" ID="optinFileUpload"></asp:FileUpload>
    <asp:LinkButton ID="btnImport" runat="server" class="btn btn-primary btn-block" OnClick="btnImport_Click" Text="Import"></asp:LinkButton>
</div>

Then I'm uploading the button and click the Import button and code behind is

protected void btnImport_Click(object sender, EventArgs e)
{
    bool val = optinFileUpload.HasFile;
}

And the val is always showing false even if it contains the file.

Can one tell me why it is always showing false

Siguza
  • 21,155
  • 6
  • 52
  • 89
Learner
  • 71
  • 13

1 Answers1

0
foreach (HttpPostedFile postedFile in FileUpload1.PostedFiles)
     {
          string fileName = Path.GetFileName(postedFile.FileName);
          postedFile.SaveAs(Server.MapPath("~/Uploads/") + fileName);
     }

http://www.itorian.com/2014/01/single-file-upload-to-multiple-file.html

Sanjay kumar
  • 1,653
  • 12
  • 18