Task:
Upload Image using external URL on our website using asp.net.
Description: Sometime we need to upload image option using URL of image(from some external resources). So that we need not to download it and then upload in our website & also need not to use external image link in our website. This code create new image in your website folder(here i used yourfolder).
We can also use it for Data-scrapping(Read Content/images from another website).
We can Resize it also. In older post I describe the resize image with maintain aspect ration here -> Upload & Resize Image
// Code Start //
// Code End//
Description: Sometime we need to upload image option using URL of image(from some external resources). So that we need not to download it and then upload in our website & also need not to use external image link in our website. This code create new image in your website folder(here i used yourfolder).
We can also use it for Data-scrapping(Read Content/images from another website).
We can Resize it also. In older post I describe the resize image with maintain aspect ration here -> Upload & Resize Image
// Code Start //
using
System.Net;
using System.IO;
using
System.Drawing;
public void
saveimage(string imageURL)
{
Stream
imageStream = new
WebClient().OpenRead(imageURL);
System.Drawing.Image img =
System.Drawing.Image.FromStream(imageStream);
string
path = Server.MapPath("yourfolder") + "\\test.jpg";
img.Save(path);
}
// Code End//