Tuesday, 10 July 2012

File Upload Code in asp.net


using System;
using System.Web.UI.WebControls;

public partial class Management_FileUpload : System.Web.UI.Page
{

  protected void Button1_Click(object sender, EventArgs e)
  {


  FileUpload FileUpload1 = file_Image;

  string virtualFolder = "~/images/tutorialimages/";

  string physicalFolder = Server.MapPath(virtualFolder);


  FileUpload1.SaveAs(physicalFolder + FileUpload1.FileName);


  lbl_Result.Text = "Your file " + FileUpload1.FileName + " has been uploaded.";

  Image1.Visible = true;
  Image1.ImageUrl = virtualFolder + FileUpload1.FileName;


  }
}

No comments:

Post a Comment