I want to download a picture using only winsock,
Is it possible to do?
If it isn't I want to download the "source code" of the picture, and save it as a picture file,
Is it possible to do?
Printable View
I want to download a picture using only winsock,
Is it possible to do?
If it isn't I want to download the "source code" of the picture, and save it as a picture file,
Is it possible to do?
I Think Is Possible But I'm Not Sure How
I Will Try To Figure Out
If Someone Else Knows It Please Help Him
I Will Try To Make It
if you want to download picture from web server, you need to send the http request for it, then the server will send you the reply and picture data, which you can save..
Yes I want to download the picture.
Can you explain me this in an example code?
For example, downloading this picture:
http://pc.co.il/_uploads/extraimg/gindis(1).jpg
You could use the URLDownloadToFile API. I've attatched a form that demos it. Here is the code:
VB Code:
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _ "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _ ByVal szFileName As String, ByVal dwReserved As Long, _ ByVal lpfnCB As Long) As Long Private Sub command1_click() Dim errcode As Long Dim url As String Dim localFileName As String 'WHAT FILE TO DOWNLOAD? url = "http://pc.co.il/_uploads/extraimg/gindis(1).jpg" 'WHERE TO SAVE IT? localFileName = "c:\gindis(1).jpg" errcode = URLDownloadToFile(0, url, localFileName, 0, 0) If errcode = 0 Then MsgBox "Download finished and saved to: " & localFileName Else MsgBox "Error while downloading" End If End Sub
Is there any way to get the file's size and a progress on how much is has downloaded?
I am asking if can I download the file using Winsock and not any API's
Yes you can do it with Winsock, why don't you search. It's much more difficult using winsock though, you have to have a decent grasp of Winsock and the HTTP protocol. Far easier to do it with the API.
I know its much easier, but I need help with the winsock.
About searching, I have searche and have not found information to help me.
You can download it with the Winsock control or you can download it and show progress. You might be able to download it with the Winsock control and show progress by subclassing the control, but using an API is a lot easier than subclassing.
never mind
I have found how to download throught winsock.