01-10-2021, Saat: 10:17
Projemde Delphi7 ile yazmış olduğum programda 80 nolu portu açarak IDHTTPServer ile bir index sayfası yayınlamak istiyorum
Fakat Localhosttan Browser ile baktığımda html görüntüleniyor sayfa yükleniyor ama resimler yüklenmiyor
bunun izahı nedir? İternette araştırdığım kodların hepsinde aynı durum.
Formun üzerinde bir adet IDHTTPServer var
active , port 80
edit1.text := 'www'; //klasörü
edit2.text:= 'index.html' //sayfası
edit3.text:= ''; //Boş
c:\proje\www\index.html dosyası ve resimler (*.jpg) projeyle aynı yerde
Fakat Localhosttan Browser ile baktığımda html görüntüleniyor sayfa yükleniyor ama resimler yüklenmiyor
bunun izahı nedir? İternette araştırdığım kodların hepsinde aynı durum.
Formun üzerinde bir adet IDHTTPServer var
active , port 80
edit1.text := 'www'; //klasörü
edit2.text:= 'index.html' //sayfası
edit3.text:= ''; //Boş
procedure TForm1.IdHTTPServer1CommandGet(AThread: TIdPeerThread;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
//INDEX
begin
if (ARequestInfo.Document='') or (ARequestInfo.Document='/') then begin
AResponseInfo.ContentType:='text/html';
IdHTTPServer1.ServeFile(AThread, AResponseinfo,'www\index.html') end else
//ERROR 404
if (ARequestInfo.Document<>'') or (ARequestInfo.Document<>'/') then
if fileexists(Edit2.Text+'\'+ARequestInfo.Document)=false then
IdHTTPServer1.ServeFile(AThread, AResponseinfo,Edit2.Text+'\'+Edit3.Text) else
//CONTENT TYPE
begin
if Pos('.GIF',ANSIUPPERCASE(ARequestInfo.Document))>0 then AResponseInfo.ContentType:='image/gif'
else if Pos('.JPG',ANSIUPPERCASE(ARequestInfo.Document))>0 then AResponseInfo.ContentType:='image/jpg'
else if Pos('.JPEG',ANSIUPPERCASE(ARequestInfo.Document))>0 then AResponseInfo.ContentType:='image/jpeg'
else if Pos('.BMP',ANSIUPPERCASE(ARequestInfo.Document))>0 then AResponseInfo.ContentType:='image/bmp'
else if Pos('.PNG',ANSIUPPERCASE(ARequestInfo.Document))>0 then AResponseInfo.ContentType:='image/png'
else if (Pos('.HTML',ANSIUPPERCASE(ARequestInfo.Document))>0) or
(Pos('.HTM',ANSIUPPERCASE(ARequestInfo.Document))>0) or
(Pos('.PHP',ANSIUPPERCASE(ARequestInfo.Document))>0) or
(Pos('.CSS',ANSIUPPERCASE(ARequestInfo.Document))>0) or
(Pos('.TXT',ANSIUPPERCASE(ARequestInfo.Document))>0) or
(Pos('.XML',ANSIUPPERCASE(ARequestInfo.Document))>0) or
(Pos('.JS',ANSIUPPERCASE(ARequestInfo.Document))>0) then AResponseInfo.ContentType:='text/html'
else AResponseInfo.ContentType:='application/octet-stream';
IdHTTPServer1.ServeFile(AThread, AResponseinfo,Edit2.Text+'\'+ARequestInfo.Document);
end; END;
c:\proje\www\index.html dosyası ve resimler (*.jpg) projeyle aynı yerde