File Upload control in Asp.Net
FileUpload control is used to upload files from the client’s system in Asp.Net. Here is an example of how we can upload a file using this control
First insert file upload control into your .aspx page.
write the following code in .aspx page
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Save" /><br />
<asp:Label ID="Label1" runat="server"></asp:Label></div>
Now write the following code in Buttons click event
string sp = Server.MapPath("images");
string fn = FileUpload1.FileName;
if (sp.EndsWith("\\") == false)
sp += "\\";
sp += fn;//Concating file name with server path
FileUpload1.PostedFile.SaveAs(sp);//saving file
Label1.Text = "File Uploaded succefully";
Try it..
Uplaod File in Asp.Net
Category:
File Upload,
File Upload control,
Uploading File
Subscribe to:
Post Comments (Atom)
Comments :
Post a Comment