how do you use RegisterFileLocation procedure from fpWebFile.pp? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Awesome Programmer · 2013-07-22 19:42 After working through my threaded http webserver program, now I am running into a different problem. I want to be able to point the http server application to a virtual folder which points an actual path on the hardrive. From what I read RegisterFileLocation procedure should let you do exactly that. So, after putting my code as follows, I try to access my webpage, but I can't see the image that supposed to display in the browser. RegisterFileLocation('files','/home/reltek/fcl-web/threaded_http'); I try to access the image as follows; http://192.168.1.117:8080/files/myscree.jpg All it displays is a broken icon to indicate broken image link. So, whats my problem? thanks for your help. ---------------------------------------------------------------------- Leledumbo · 2013-07-22 21:41 Probably wrong mimetype, which defaults to application/octet-stream. Set MimeTypesFile to path to a file containing mimetypes definition at the start of your program (or at unit initialization). ---------------------------------------------------------------------- Awesome Programmer · 2013-07-23 12:39 How is about the following code? Is that sufficient? Code: [Select]Procedure TForm1.Create; begin RegisterFileLocation('files','/home/reltek/fcl- web/threaded_http'); MimeTypesFile := '/etc/mime.types'; end; Here is the HTML page Response from the HTTP server. Code: [Select]procedure TForm1.DoHandleRequest(Sender: TObject; var ARequest: TFPHTTPConnectionRequest; var AResponse: TFPHTTPConnectionResponse); begin AResponse.Content:='
';
end;
I still don't see the image but I do see the text.
----------------------------------------------------------------------
Leledumbo · 2013-07-23 15:41
And what happens if you view source and click the image link directly?
----------------------------------------------------------------------
Awesome Programmer · 2013-07-23 15:50
Here is what I see. Take a look at my attached image. I am using
FireFox.
As you can see, I can see everything except the image.
UPDATE: just as a test, I hot linked an image directly from our
company's website webserver and it worked. Only when I say,Code:
[Select] /files/myscreen.jpg orCode: [Select]
http://192.168.1.117:8080/files/myscreen.jpg from Lazarus' HTTP
webserver it doesn't work. So, what is the difference here?
----------------------------------------------------------------------
Leledumbo · 2013-07-23 21:29
QuoteI hot linked an image directly from our company's website
webserverDo you mean it points to image in an external server? It
would be totally different since the web browser will query the
external server instead of your application.
Try the attached project (don't forget to adjust the path in .lpr),
and ensure you get the same result (HTTP 200 OK) in your browser's
developer tools (screenshot attached). At the worst, your browser
should download the image instead of displaying it.
----------------------------------------------------------------------
Awesome Programmer · 2013-07-24 13:39
Thanks for the sample project. I got it debugging, but when I request
the page from your sample http server I get the following errors. See
the attached image.
Am I doing this right?
----------------------------------------------------------------------
Leledumbo · 2013-07-24 17:01
Ah, sorry. I forgot to mention the URL: http://