0

I want to upload image in my form .i don't want to save image on server before submit. i want to save image on the server click on the submit button .

pargan
  • 301
  • 3
  • 6
  • 19

1 Answers1

1
if(FileUpload1.HasFile){
    string absolute_path=MapPath("~/" + FileUpload1.FileName);
    string relative_path="~/" + FileUpload1.FileName;
    FileUpload1.SaveAs(absolute_path);
    Image1.ImageUrl=relative_path;
}

You can use this code for uploading an image.

If you want to save after a button click then write like this

private void ButtonUpload_Click(object as Sender...)
{
    FileUpload1.SaveAs(absolute_path);
}
Kishore Kumar
  • 12,675
  • 27
  • 97
  • 154
  • thanks for reply but i want to upload multiple image . using this we can only upload only one image – pargan Mar 23 '12 at 08:33
  • @pargan: do you want to upload several images? – Oleks Mar 26 '12 at 16:30
  • yes alex i want to upload Three images . but on upload i also want to show image to user. after that then the user submit images and other information save on the server. – pargan Mar 27 '12 at 05:13
  • 1
    @pargan: then take a look at `Request.Files` property – Oleks Mar 27 '12 at 15:39