c# - File upload button not showing files when uploaded -


i have modal popup , in modal-body have 2 asp.net controls fileupload control , linkbutton , 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 button , click import button , code behind is

protected void btnimport_click(object sender, eventargs e) {     bool val = optinfileupload.hasfile; } 

and val showing false if contains file.

can 1 tell me why showing false

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


Comments