Did you placed the trigger inside <update panel>
like
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="btnUploadFile" />
</Triggers>
<rest of the code>
</asp:UpdatePanel>
Taken from this post FileUpload.hasFile is always False
If it's still not working then try placing your FileUpload control outside UpdatePanel
and see if it works. Reasoning: you should not be placing a FileUpload
control inside an UpdatePanel
because the UpdatePanel
sends an AJAX request to the server.
Make sure that the credential using which you are running web application has access to the file. In other words it's not a file permission issue
.
you can also use FileUpload
controls FileName
property like
if (FileUpload1.FileName != string.Empty)