tags:

views:

235

answers:

2

I have url that point to image for example : http://cg009.k12.sd.us/images/smilefacemoving.gif

instead of user will insert file i want to bind this file(image) to the c# fileupload control .

so the fileupload object will hold this file(image).

A: 

I'm honestly not sure what you're asking. Are you asking how you can upload a file referenced via a URL to your own server utilizing the fileupload control?

alex
yes!
avnic
+1  A: 

Just have a Textbox on your page to let them enter a URL and then do this when the form is submitted...

string url = YOUR_TEXTBOX.Text();
Uri uri;

try {
 uri = new Uri(url);
}
catch (UriFormatException ex) {
 // Error
 throw ex;
}

byte[] file;

using (System.Net.WebClient client = new System.Net.WebClient()) {
 file = client.DownloadData(uri);
}

// now you have the file

Watch out for uploaded viruses :)

Josh Stodola