Click here to Skip to main content
15,941,304 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi guys,

I'm writing a web page/application for my client in ASP.NET/C# which allows them to manage the content on their intranet by creating articles containing text and images, etc.

As part of their content management system, they want to be able to copy the URL of an image from somewhere else on the internet, paste the URL into a text box, and then click the submit button so the page will upload that file to their server where they can use it in their own articles later on.

Sounds straight forward enough, but the problem is that their own server is not allowed to connect to the internet itself due to security restrictions so I can't do the image grabbing on the server side, it has to be done on the client and then posted to the server - presumably using some sort of Javascript/AJAX. So what would be the best solution to do this? I'm wondering if it could maybe be done using a combination of Javascript and IFrames?

I could of course just require the user to save the image down to their own local drive, and then browse to it using a standard 'asp:FileUpload' control - but they don't want that, they just want to paste the URL into the textbox and then it saves to the server automatically.

I am also restricted to using only IE 8.0 as this is an internal application and they don't support other browsers.

Any help much appreciated!

Nick
Posted
Updated 7-Apr-13 22:18pm
v3

OK, after much research, I've answered my own question and come to the conclusion that this can't be done in IE8.

The solution that I thought would be most viable would be to load the image into a hidden DIV on the page and then grab it using a third party plugin before posting it to the server using AJAX. And this method DOES seem possible - but not using IE8.

There's a very useful library called HTML2Canvas which does exactly that, using the 'canvas' element of HTML5 - but of course, this only works on other browsers like FF and Safari, and IE versions of 9 or above. As seen on the examples page here, the library gives an "Object doesn't support this property or method" when run through IE8:

http://html2canvas.hertzen.com[^]

There are apparently ways around this, as there are other libraries out there that successfully emulate the same canvas functionailty in IE8 - most notably Google's 'Explorer Canvas', and also 'FlashCanvas'. But while these both provide the majority of functions you get with a normal HTML5 canvas, they do not provide the critical function required called 'toDataURL' - which allows you to grab the canvas from the screen. Even though FlashCanvas now claims to support this function, having tried it for several hours I'm convinced that this cannot be used with HTML2Canvas for the purpose I need it for.

Having browsed around on other forums, it seems that other people are also having problems trying to get this solution working, and so for now I'll have to rule it out and devise some other way round it. Hopefully this might be of some use to anyone else attempting the same thing.


Cheers


Nick
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900