Board index » cppbuilder » How to return a file to client by using IdHttpServer

How to return a file to client by using IdHttpServer


2004-03-03 03:10:58 PM
cppbuilder33
I can successfully pass any string to ResponseInfo->ResponseText
and pass it back to client. but if i want to respond client a graphic file to download how do it do it? thanks
 
 

Re:How to return a file to client by using IdHttpServer

"andy Huang" < XXXX@XXXXX.COM >wrote in message
Quote
if i want to respond client a graphic file to download how do it do it?
Simply call the server's ServeFile() method. For example:
void __fastcall TForm1.IdHTTPServer1CommandGet(TIdPeerThread *AThread,
TIdHTTPRequestInfo *ARequestInfo, TIdHTTPResponseInfo *AResponseInfo)
{
if( ARequestInfo is asking for a file )
IdHTTPServer1->ServeFile(AThread, AResponseInfo, "the full path
and name of the file to send");
}
Gambit
 

Re:How to return a file to client by using IdHttpServer

I can successfully pass any string to ResponseInfo->ResponseText
and pass it back to client. but if i want to respond client a graphic file to download how do it do it? thanks
 

{smallsort}

Re:How to return a file to client by using IdHttpServer

so here is what i tried (assume that idhttp client to send request and use localhost to test it out), can't open file
C:etinstall.txt anyone knows what's go wrong? thanks
void __fastcall TForm1::IdHTTPServer1CommandGet(TIdPeerThread *AThread,TIdHTTPRequestInfo *RequestInfo, TIdHTTPResponseInfo *ResponseInfo)
{
IdHTTPServer1->ServeFile(AThread,ResponseInfo,"C:\etinstall.txt");
}
"Remy Lebeau \(TeamB\)" < XXXX@XXXXX.COM >wrote:
Quote

"andy Huang" < XXXX@XXXXX.COM >wrote in message
news:40458502$ XXXX@XXXXX.COM ...

>if i want to respond client a graphic file to download how do it do it?

Simply call the server's ServeFile() method. For example:

void __fastcall TForm1.IdHTTPServer1CommandGet(TIdPeerThread *AThread,
TIdHTTPRequestInfo *ARequestInfo, TIdHTTPResponseInfo *AResponseInfo)
{
if( ARequestInfo is asking for a file )
IdHTTPServer1->ServeFile(AThread, AResponseInfo, "the full path
and name of the file to send");
}


Gambit


 

Re:How to return a file to client by using IdHttpServer

"andy Huang" < XXXX@XXXXX.COM >wrote in message
Quote
IdHTTPServer1->ServeFile(AThread,ResponseInfo,"C:\etinstall.txt");
You need to double up on the backslash:
IdHTTPServer1->ServeFile(AThread, ResponseInfo,"C:\\etinstall.txt");
Gambit