Tuesday, 16 September 2014

File Upload

If you want to upload a file or image. Following code can be used.

if (FileUpload1.HasFile)
        {
            FileUpload1.SaveAs(Server.MapPath("uploading\\") + FileUpload1.FileName);
            Image.ImageUrl = "~\\uploading\\" + FileUpload1.FileName;
            Label.Text = FileUpload1.FileName;

        }

Note: 
  • In the above code uploading is the folder name in which your uploaded files will be saved.
  • Image. ImageUrl  is the image button to show our uplaoded file/picture(if required).
  • Label.Text is label button to show the url of your file.(paths showing where it hass been take from your computer)

No comments:

Post a Comment