[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Upload from URL, not local file system

Posted on 2008-10-02
4
Medium Priority
?
225 Views
Last Modified: 2013-11-07
Have to admit, I know nothing about .NET and come from a classic ASP world as far as server-side programming goes... Anyway.

What we're looking to do is to upload an image from a user provided URL to server, rather than prompting user for a file on their computer.

To demonstrate behaviour:
have a look at http://imageshack.us/

upload: http://img.youtube.com/vi/PTU2He2BIc0/default.jpg

results in the image being hosted at:

http://img440.imageshack.us/img440/8094/defaultgh3.jpg

The company that I now work for is a .NET shop that has recently migrated to 2.0 and uses a third party component http://www.powupload.com/ for it's current uploading needs.

Thanks for your thoughts.

N
0
Comment
Question by:steam23
3 Comments
 
LVL 15

Expert Comment

by:Solar_Flare
ID: 22630395
to do this you would just use a TextBox to enter the URL, then when a button is clicked you would get the server to retrieve the file at the given URL

eg


void UploadHandler(object sender, eventargs e)
{
   if(Textbox1.text != string.empty)
   {
      System.Net.WebClient c = new System.Net.WebClient();
      byte[] imageBytes = c.DownloadData(TextBox1.Text);
      //now save imagebytes or whatever
   }
 
}

Open in new window

0
 

Author Comment

by:steam23
ID: 22630457
I guess this would be customizing of how powupload handles being passed a string?
0
 
LVL 10

Accepted Solution

by:
GeoffSutton earned 1000 total points
ID: 22634731
No... that would bypass powerupload altogether :)  Also if you are going to be uploading the file from a local URL you would probably want to add Javascript to resolve mapped drives:
This will take care of that, although it requires using activeX not marked as safe.  It will need to be rewritten for Firefox (I wrote it for an intranet situation).

Once you have the byte stream you should be able to take the stream and channel it directly into the database "Image" column, along with additional metadata.  Then you can stream the data out again simply.  Using this method you are not limited to just images either:  You can store video, audio or any other Binary.  All you need do is make sure you have the MIME content type stored so you can set that on the output page.

Doing this should speed the process some, since right now it seems fairly slow.

Hope this helps,
Geoff

   function getUNCPath(){
            var file1=document.getElementById("file1");
            var fso = new ActiveXObject("Scripting.FileSystemObject");
            var path=file1.value;
            var strDrive;
            var strShare;
            strDrive=fso.GetDriveName(path);
            strShare=fso.Drives(strDrive).ShareName;
            var unc=path.replace(strDrive,strShare);
            document.getElementById("uncPath").value=unc;
            return;
        }

Open in new window

0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month18 days, 1 hour left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question