pargan
pargan

Reputation: 311

upload image on server after submit in c#?

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 .

Upvotes: 0

Views: 1195

Answers (1)

Kishore Kumar
Kishore Kumar

Reputation: 12884

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);
}

Upvotes: 1

Related Questions