upload the image and display it

Last post 12-03-2008, 4:11 AM by david.brown. 0 replies.
Sort Posts: Previous Next
  •  12-03-2008, 4:11 AM Post number 70750

    upload the image and display it

    hi all,

    I want to upload the image in on folder and than display it onto page.I use this code for upload the image

    public partial class _Default : System.Web.UI.Page

    {
       protected void Page_Load(object sender, EventArgs e)
       {
     }
       protected void Button1_Click(object sender, EventArgs e)
      {
     string ImagesFolder = "MatchImages";
    string savePath;
    string saveFile;
    if (FileUpload1.HasFile)
    {
    try
    {
    // perform the upload
    //http://www.infysolutions.com
    savePath = Path.Combine(Request.PhysicalApplicationPath,
    ImagesFolder);
    saveFile = Path.Combine(savePath, FileUpload1.FileName);
    FileUpload1.SaveAs(saveFile);
    // Displays status of success
    FileUploadReport.Text = "Your file was uploaded successfully.";
    }
    catch(Exception exUpload)
      {
    // display status of error
    FileUploadReport.Text = exUpload.Message;
    }
    }
    else // probably file was not selected
    {
    // Display status of failure
    FileUploadReport.Text = "You did not specify a file to upload.";
    }
    }

    Software development company

View as RSS news feed in XML