Thread View: borland.public.cppbuilder.internet.socket
3 messages
3 total messages
Started by Lapo Guidi
Thu, 19 May 2005 01:20
TIdHTTPServer and ServeFile
Author: Lapo Guidi
Date: Thu, 19 May 2005 01:20
Date: Thu, 19 May 2005 01:20
30 lines
2122 bytes
2122 bytes
Hi all, I made a small and simple HTTP Server using Indy. I would like to send a file to the client (eg. test.zip). Browser ask to receive the file using a sort of dynamic page called sendfile.html with parameter. In other words the url requested from the client is that: http://localhost/sendfile.html?name=test.zip The problem I have is that: If I click over the link in a page using the client (Internet Explorer), the zip file is written on the html page. If I right-click on the link and I choose "Save target as..." the zip is correctly saved where I want, but the name is sendfile.html. I use this row of code in the OnCommandGet: HTTP->ServeFile(AThread, AResponseInfo, "c:\\test.zip"); but I tried also sending the file using ContentStream properties and the result is the same. In two words, when I click on a link to request a file, it's displayed over the browser (instead of saved on disk) and if I right-click on the link, the file is saved but with a wrong filename. What I'm do wrong? What's the right procedure to send a file requested with a sort of dynamic page? I hope I was sharp enough. Thanks very much Lapo
Re: TIdHTTPServer and ServeFile
Author: Remy Lebeau (TeamB)
Date: Thu, 19 May 2005 10:28
Date: Thu, 19 May 2005 10:28
22 lines
1788 bytes
1788 bytes
"Lapo Guidi" <lapoguidi@inwind.it> wrote in message
news:428be9c6@newsgroups.borland.com...
> If I click over the link in a page using the client (Internet Explorer),
> the zip file is written on the html page. If I right-click on the link
> and I choose "Save target as..." the zip is correctly saved where
> I want, but the name is sendfile.html.
You are not specifying the proper header values to let the browser know that
the file is downloadable, and what its filename should be.
> I use this row of code in the OnCommandGet:
> HTTP->ServeFile(AThread, AResponseInfo, "c:\\test.zip");
Add the following line of code before calling ServeFile():
AResponseInfo.CustomHeaders.Values['Content-Disposition'] :=
'attachment; filename="test.zip"';
Gambit
Re: TIdHTTPServer and ServeFile
Author: Lapo Guidi
Date: Sat, 21 May 2005 16:26
Date: Sat, 21 May 2005 16:26
5 lines
961 bytes
961 bytes
Thanks Remy, it seems to works properly. At the next :) Lapo
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads