[SOLVED]Detect that file is on server with fphttpclient? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Robert W.B. · 2017-02-13 13:09 Hi. Is there a way to detect, if a file exists on the server, with fphttpclient?  Thanks in advance Bob ---------------------------------------------------------------------- rvk · 2017-02-13 13:36 You could use HEAD to see if the page (or file) exists. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1;uses fphttpclient, Classes;var  Fp: TFPHttpClient;begin  Fp := TFPHttpClient.Create(nil);  try     Fp.HTTPMethod('HEAD', 'http://www.microsoft.com/I_DO_NOT_EXIST.html', nil, []);    Writeln(Fp.ResponseStatusCode); // will give 404     Fp.HTTPMethod('HEAD', 'http://www.microsoft.com/nl-nl/windows', nil, []);    Writeln(Fp.ResponseStatusCode); // will give 200   finally    Fp.Free;  end;  readln;end. ---------------------------------------------------------------------- Thaddy · 2017-02-13 13:47 That is correct. Note ONLY for files that are in the public part of your server. That code can not detect if a file exists anywhere outside of the serve-able space on that server disk. In other words, you can not detect the presence of a specific file if it is not serve-able. ---------------------------------------------------------------------- rvk · 2017-02-13 13:57 It also doesn't account for redirection. Lot's of file-services use redirection for files. In that case you will always get a 3xx redirect on every possible filename. So if that's the purpose you need to do some manual work to follow the redirection to its final source and see if it throws an error-page. So, if you need more information you will also need to provide us with more information. ---------------------------------------------------------------------- Robert W.B. · 2017-02-13 13:59 This is what I was looking for. Have a great day. /Bob