Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jun : Re: problem loading pictures of web page using TidHTTPServer and TPageProducer
| Subject: | Re: problem loading pictures of web page using TidHTTPServer and TPageProducer |
| Posted by: | "Glen Welch" (gl..@custommadesoftware.co.nz) |
| Date: | Tue, 6 Dec 2005 16:45:00 +1300 |
This is the only coding I have - sorry only new to using the http server so
am probably missing something...
procedure TIMain.HTTPServerCommandGet(AThread: TIdPeerThread;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
LocalDoc: String;
begin
LocalDoc := ExpandFilename(ExtractFilePath(Application.ExeName) + '\web
site' + ARequestInfo.Document);
if not FileExists(LocalDoc) and DirectoryExists(LocalDoc) and
FileExists(ExpandFileName(LocalDoc + 'index.htm')) then
begin
LocalDoc := ExpandFileName(LocalDoc + 'index.htm');
end;
if FileExists(LocalDoc) then // File exists
begin
htmlPageProducer.HTMLFile := LocalDoc;
AResponseInfo.ContentText := htmlPageProducer.Content;
AResponseInfo.ContentType := 'text/html';
end;
end;
The page index.htm was written using Front Page and contains 3 images that
do not display when the page is loaded into IE- when I use
HTTPServer.ServeFile(AThread, AResponseInfo, LocalDoc) all works fine.
"Glen Welch" <glen@custommadesoftware.co.nz> wrote in message
news:44a1d68f@newsgroups.borland.com...
> Following is some code I am using to fill in Tags from a web page - then
> send it using TidHTTPServer.
> Im not sure if this is the best way of doing this but I cant get it to
> work at all.
> If there is a better way of filling in tags then please let me know cause
> as you can see I am having to save out to the tempary file.
>
> htmlPageProducer: TPageProducer;
> HTTPServer: TIdHTTPServer;
>
> if FileExists(LocalDoc) then // File exists
> begin
> htmlPageProducer.HTMLFile:= LocalDoc;
> TempFileName:= ChangeFileExt(LocalDoc, '.tmp');
> TempFile:= TStringList.Create;
> try
> TempFile.Add(htmlPageProducer.Content);
> TempFile.SaveToFile(TempFileName);
> finally
> TempFile.Destroy;
> end;
> HTTPServer.ServeFile(AThread, AResponseInfo, TempFileName);
> end;
>
> Problem is that images are not being displayed.
>
> If i use
> HTTPServer.ServeFile(AThread, AResponseInfo, LocalDoc);
> all works fine
>
> Thanx in advance.