Reputation: 121
i need to get the filename from my input id is Announcement_PIC, but it always return null when i try to get the filename. below is my code:
Front side:
<input type="file" runat="server" class="textboxTabsFiles" ID="Announcement_PIC"/>
Backend: i've already included the below in the partical class:
protected System.Web.UI.HtmlControls.HtmlInputFile File1;
protected System.Web.UI.HtmlControls.HtmlInputButton Submit1;
This is how i'm currently getting my filename
string fn = System.IO.Path.GetFileName(Announcement_PIC.PostedFile.FileName).ToString();
Edit: my file upload is placed inside a JQuery tabs and using the asp fileupload it also has problem getting the file name, thus i tried using input file
Upvotes: 1
Views: 9032
Reputation: 10012
Why not use:
<asp:FileUpload id="FileUploadControl" runat="server" />
That will allow you to access .HasFile & also perform .SaveAs
Upvotes: 1
Reputation: 3835
Have you remembered a enctype='multipart/form-data'
on the form-tag?
Upvotes: 1