?
Solved

Upload from URL, not local file system

Posted on 2008-10-02
4
Medium Priority
?
221 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

801 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