Question: The service response file SRF directly transmits the code snippet of the image stream to the client browser
Cheungmine
Question: How to directly write image data to a stream from the Web server and display it in the client browser
Why: efficiency and security. Do not generate temporary files. Full memory operation.
I used vs2005 to create an ATL server project and merge isapis. Others are as usual. Project name: refreshimg. Automatically create virtual directories with the same name and deploy them automatically.
1) rewrite the following code in the refreshimg. h file:
// The following is an example of how to use the replacement tag for a mold (stencer) processor.
Http_code onhello (void)
{
// M_httpresponse <"Hello world! ";
Char Buf [4096];
Size_t cbread;
DWORD dwwritten;
M_httpresponse.clearcontent ();
M_httpresponse.setcontenttype ("image/JPEG ");
// The image file below must exist
File * fp = fopen ("C: // inetpub // wwwroot // refreshimg // obm_skq.jpg", "Rb ");
While (cbread = fread (BUF, 1, 4096, FP)> 0 ){
If (s_ OK! = M_httpresponse.writestream (BUF, cbread, & dwwritten) | cbread! = Dwwritten ){
Fclose (FP );
Return http_fail;
}
}
Return http_success;
}
2) rewrite refreshimg. SRF:
<HTML>
{Handler refreshimg. dll/default }}
<Head>
</Head>
<Body>
</Body>
</Html>
3) regenerate all solutions, and then use IE or FF to open
Http: // localhost/refreshimg. SRF
You can see the image.
You can also write a new refresh.htm webpage, as shown below:
<HTML>
<Head>
<Title> cheungmine </title>
</Head>
<Body>
</Body>
</Html>
Put refresh.htm in the same directory as refreshimg. SRF.
In this case, you can view the refresh.htm image:
>
. Net. But this article has nothing to do with. net.