boutique replica bags up ideas

the best replique rolex and prices here.

julia highlight 99j hair color 10a quality straight human hair lace front wigs 8 - 24 inches pre plucked hairline 13x4 inches lace front brazilian wig onlinefor sale

Restrict User to Upload only specific type of files in ASP.NET

Updated on     Kisan Patel

This tutorial will show you how to restrict the user to upload only specific type of files (.gif, .png or .jpg file) in ASP.NET?

Default.aspx

<p><asp:FileUpload runat="server" ID="FileUpload1" /></p>
<p><asp:Button ID="Button1" OnClick="UploadFile" runat="server"
Text="Upload Specific Type of File" />

Default.aspx.cs

Namespace:

using System.IO.Path.GetExtension;

Code:

protected void UploadFile(object sender, EventArgs e)
{
      string fileName = FileUpload1.PostedFile.FileName;
      string extension = Path.GetExtension(fileName);
      if (extension.Equals(".jpg") || extension.Equals(".gif") || extension.Equals(".jpg"))
      {
          string path = Server.MapPath("~/images/");
          FileUpload1.SaveAs(path + fileName);
          Response.Write("File uploaded successfully !");
      }
      else
      {
          Response.Write("upload only .jpg, .gif or .png file!");
      }
}

ASP.NET

Leave a Reply