Solved

Upload from URL, not local file system

Posted on 2008-10-02
4
220 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 250 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 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