473,385 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Getting image from wewbsite

Does anybody know how you can extract an image fron a webpage loaded into a
webbrowser control and either save it to file OR save it in a database?

Cheers,
Johnny J.
Nov 16 '07 #1
10 1831


"Johnny Jörgensen" <jo**@altcom.sewrote in message
news:Ot**************@TK2MSFTNGP02.phx.gbl...
Does anybody know how you can extract an image fron a webpage loaded into
a webbrowser control and either save it to file OR save it in a database?

Cheers,
Johnny J.
You need to read in the image as if you were reading in a webpage....first,
open the web page and parse the path to the image...then, you can use the
following code to get the byte-array of the image and store to a file or
data column in a database.

// BEGIN C#

string url =
@"http://www.co.merced.ca.us/CountyWeb/images/GeneralActive.gif";
HttpWebRequest request =
(HttpWebRequest) WebRequest.Create(url);
HttpWebResponse response =
(HttpWebResponse) request.GetResponse();

byte[] bytes;
using (Stream stream = response.GetResponseStream()) {
bytes = new byte[response.ContentLength];
stream.Read(bytes, 0, bytes.Length);
}

// Now we have a byte array to do as we wish, saving to a file
now.
FileStream fs = File.Create(@"C:\GeneralActive.gif");
fs.Write(bytes, 0, bytes.Length);
fs.Close();

// OR write to a database.
// To do this, create an IMAGE (SQL Server) column and just copy
// the byte array into the field for a DataRow. An Image column
// maps to a byte-array in a DataColumn in a DataRow.

// END C#

There may be an easier or better way in a more recent version of the .Net
Framework though... :)
HTH,
Mythran

Nov 16 '07 #2
Johny,

As soon as you know its url location you can download it using

DownloadFile
http://msdn2.microsoft.com/en-us/lib...le(VS.71).aspx

To get that in a webbrowser you mostly needs a lot of mshtml

http://support.microsoft.com/kb/311284

Cor

Nov 16 '07 #3
"Johnny Jörgensen" <jo**@altcom.seschrieb:
Does anybody know how you can extract an image fron a webpage loaded into
a webbrowser control and either save it to file OR save it in a database?
'My.Computer.Network.DownloadFile'
'System.Net.WebClient.DownloadFile'

You can store the binary data in the database as a BLOB.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 16 '07 #4
Thanks for the suggestions all of you.

Howevet, having had time to think about it, it seems like I'm missing
something here.

You see, as I wrote, I already have a webpage loaded in a webbrowser
containing the image I want to save to a database field.

So there should be no reason for downloading it AGAIN (using extra time to
do that). There MUST be a way to "pluck out" the image from the webbrowser
control in a form that's database saveable.

Cheers,
Johnny J.

"Johnny Jörgensen" <jo**@altcom.seskrev i meddelandet
news:Ot**************@TK2MSFTNGP02.phx.gbl...
Does anybody know how you can extract an image fron a webpage loaded into
a webbrowser control and either save it to file OR save it in a database?

Cheers,
Johnny J.

Nov 16 '07 #5
Johnny,

The following will help you do what you want:

http://msdn2.microsoft.com/en-us/lib...3052001_topic2

Be aware, however, that because of security issues, the UI to indicate
where to save the image must be presented, there is no way around it.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Johnny Jörgensen" <jo**@altcom.sewrote in message
news:Od*************@TK2MSFTNGP03.phx.gbl...
Thanks for the suggestions all of you.

Howevet, having had time to think about it, it seems like I'm missing
something here.

You see, as I wrote, I already have a webpage loaded in a webbrowser
containing the image I want to save to a database field.

So there should be no reason for downloading it AGAIN (using extra time to
do that). There MUST be a way to "pluck out" the image from the webbrowser
control in a form that's database saveable.

Cheers,
Johnny J.

"Johnny Jörgensen" <jo**@altcom.seskrev i meddelandet
news:Ot**************@TK2MSFTNGP02.phx.gbl...
>Does anybody know how you can extract an image fron a webpage loaded into
a webbrowser control and either save it to file OR save it in a database?

Cheers,
Johnny J.

Nov 17 '07 #6
Johnny,

There is no image loaded in your webbrowser, a webbrowser is just using the
IE part of the OS. In the pages there is an image tag to the url about we
all are talking about in a way. That URL you can find using MSHTML (Which is
nothing more then the representation of the DHTML object model often called
***the*** DOM).

Cor

Nov 17 '07 #7

"Joey Joe Joe" <no@nothing.comschreef in bericht
news:%2***************@TK2MSFTNGP03.phx.gbl...
That's exactly where they are. They're in your Temporary Internet Files
folder.
Which you could find in W98 and IE4 direct in the C drive folder, however a
little bit changed.

In XP it has all kind of GUID like other names, in Vista I don't even see it
even anymore.

Beside that are images mostly very short in cache because that they have
mostly a retention time of 0.

Cor

Nov 18 '07 #8
That's because the folder is hidden, but it's still there. In Vista (unless
you move it):

C:\Users\.....\AppData\Local\Microsoft\Windows\Tem porary Internet Files

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:A7**********************************@microsof t.com...
>
"Joey Joe Joe" <no@nothing.comschreef in bericht
news:%2***************@TK2MSFTNGP03.phx.gbl...
>That's exactly where they are. They're in your Temporary Internet Files
folder.
Which you could find in W98 and IE4 direct in the C drive folder, however
a little bit changed.

In XP it has all kind of GUID like other names, in Vista I don't even see
it even anymore.

Beside that are images mostly very short in cache because that they have
mostly a retention time of 0.

Cor
Nov 18 '07 #9

"Joey Joe Joe" <no@nothing.comwrote in message
news:um**************@TK2MSFTNGP02.phx.gbl...
That's because the folder is hidden, but it's still there. In Vista
(unless you move it):

C:\Users\.....\AppData\Local\Microsoft\Windows\Tem porary Internet Files

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:A7**********************************@microsof t.com...
>>
"Joey Joe Joe" <no@nothing.comschreef in bericht
news:%2***************@TK2MSFTNGP03.phx.gbl...
>>That's exactly where they are. They're in your Temporary Internet Files
folder.
Which you could find in W98 and IE4 direct in the C drive folder, however
a little bit changed.

In XP it has all kind of GUID like other names, in Vista I don't even see
it even anymore.

Beside that are images mostly very short in cache because that they have
mostly a retention time of 0.

Cor
Simplest way to find the temp files in Vista is to use Tools/Internet
Options/General Tab.

Click on Settings then View Files

LS

Nov 18 '07 #10
Thanks Lloyd,

Nov 18 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: karimL | last post by:
Hi, how can I retrieve the height and width of a System.Web.UI.WebControls.Image after populating it's ImageUrl property. It's seems not to be filled ? Does someone have a solution ? Thanks...
11
by: KarimL | last post by:
Thanks for your advices... but i need to get the Image height because i dynamically resize the height of my webcontrol based on the image height. More i just have the url (relative parth) to the...
3
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are...
5
by: Aryan | last post by:
Hi All, I am creating an image(.gif) file on server Using ASP and ShotGraph Third Party Tool, now with the help of this .gif image I am creating another Thumbnail image in ASP.NET. Now this newly...
2
by: soma.gunasekaran | last post by:
Hi All , I've stored the Image file..... But i want to retriving the Image files from MSACCSS 2003 (JPEG,bmp,Gif and etc....) So Pls help me........ help me............... Thanking you,...
3
by: Andrzej | last post by:
I have a picturebox on my C# .NET form. The picturebox size mode is set to zoom. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and...
5
by: Emmi | last post by:
Hi there, just starting in PHP and found some code that would switch out pages depending on link clicked. It worked great loading different pages. Then I thought I would try the same code by...
10
by: Johnny Jörgensen | last post by:
Does anybody know how you can extract an image fron a webpage loaded into a webbrowser control and either save it to file OR save it in a database? Cheers, Johnny J.
2
by: hgarg | last post by:
The onpaint() is getting called before calculating the required parameters by listBox1_SelectedIndexChanged function. I tried calling it at the end of this function. But of no use. Due to this issue...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.