using wininet to get a gif file

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
When I try to use wininet to make a GET request to get a gif file, and I save the file locally to my computer, the image appears corrupted when I open it (I can see that part of the image is intact, but most of it is corrupted). Is there anything special
I need to do to read a gif file with wininet? I am using the same code that I use to read a webpage. Is there something that needs to be done different when reading a gif file? Here is part of the code that I am using:
<pre class="prettyprint" style=" char * hdrs="Content-Type: application/x-www-form-urlencodednAccept-Encoding: identity";<br/>LPCSTR accept[2]={"*/*", NULL}; HINTERNET hSession = InternetOpen(TEXT("http generic"),INTERNET_OPEN_TYPE_PRECONFIG , NULL, NULL, 0);
HINTERNET hConnect = InternetConnect(hSession, TEXT("mywebsite.com"),INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1);
ofs5.open("C:/Users/me/7myimage.gif"); HINTERNET hRequest = HttpOpenRequest(hConnect, "GET","/c91cba747b489.gif", NULL, NULL, accept, 0, 0);
bool send=HttpSendRequest(hRequest, hdrs, strlen(hdrs), NULL,NULL);
char* buffs0[10000];
readfile(hRequest,buffs0,10000,ofs5); [/code]
Thanks.
Andrew
<br/>
<br/>
<br/>

View the full article
 
Back
Top