2

I know how to save an image to a folder using the fileupload control with the saveas method. But I to take an image from the image control and save it to a file without using the fileupload control n save it in folder.

Kiran Solkar
  • 1,204
  • 4
  • 16
  • 29

3 Answers3

2
string filepath = img1.ImageUrl;           
using (WebClient client = new WebClient())
{
       client.DownloadFile(filepath,Server.MapPath("~/Image/apple.jpg"));
}
Kiran Solkar
  • 1,204
  • 4
  • 16
  • 29
1

Do you know image path? you can get image path from image control and then download image in code:

Download image from the site in .NET/C#

using(WebClient client = new WebClient()) 
{
    client.DownloadFile("http://www.example.com/image.jpg", localFilename); 
} 
Community
  • 1
  • 1
fenix2222
  • 4,602
  • 4
  • 33
  • 56
1

First Get the Url of Image and then using webclient you can save file in folder

string filepath = img1.ImageUrl;           
using (WebClient client = new WebClient())
{
       client.DownloadFile(filepath,Server.MapPath("~/Image/apple.jpg"));
}

This will save image in Image Folder with ImageName apple...

Kartik Patel
  • 9,303
  • 12
  • 33
  • 53