How does one specify a file to download lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- stab · 2013-05-24 17:31 Hi, Webserver: Apache 2.2.22 on Windows Server 2003 I'm trying to use synapse to download a file from a server disk. Found following code on the net:   procedure DownloadFile;   var     httpClient: THTTPSend;   begin     httpClient:= THTTPSend.Create;     if httpClient.HTTPMethod('GET', 'http://code.sd/turbobird/main.jpg') then       httpClient.Document.SaveToFile('main.jpg');     httpClient.Free;   end; In my case the file path is  E:\download\customer1\test.exe How do I specify the file using synapse httpClient? Regards stab ---------------------------------------------------------------------- Leledumbo · 2013-05-24 18:12 Does the server provide HTTP access? If yes, just use that code, modifying URL to the file (you do know server's ip address, don't you?). Note that you must configure the server to serve files from the directory you want. ---------------------------------------------------------------------- stab · 2013-05-24 20:44 Thanks for answering, Yes the server provide HTTP access. From your answer I guess the problem is about configuring the server to serve files from a specific directory. That means that I have to learn more about httpd.conf, or what? Regards stab ---------------------------------------------------------------------- Giu · 2013-05-24 21:10 Quote from: stab on May 24, 2013, 07:31:54 pmHi, Webserver: Apache 2.2.22 on Windows Server 2003 I'm trying to use synapse to download a file from a server disk. Found following code on the net:   procedure DownloadFile;   var     httpClient: THTTPSend;   begin     httpClient:= THTTPSend.Create;     if httpClient.HTTPMethod('GET', 'http://code.sd/turbobird/main.jpg') then       httpClient.Document.SaveToFile('main.jpg');     httpClient.Free;   end; In my case the file path is  E:\download\customer1\test.exe How do I specify the file using synapse httpClient? Regards stab You can't access any folder on a server via http is not properly configured in server.  E:\download\customer1\test.exe is where you want to download on your drive, or when the file is in the server? If you want to download a file served via http, this file must be on a folder with public access. Something like http://example.com/files/test.exe This file should be physically in a folder inside web root, something like var/www/files/test.exe in Linux, or int windows (typical xampp installation for example) in c:\xampp\htdocs\files\test.exe Obviously this is a lot more complex and could be a lot of possibilities, for this reason, I ask. Have you the possibility to download from an Internet browser? ---------------------------------------------------------------------- stab · 2013-05-25 08:48 Hi Giu, E:\download\customer1\test.exe is on the server. Am building the web-app using Raudus and have a structure with a download-dir per customer. The app allows me to display the content in a customers dir in a listbox for download selection. Haven't heard of XAMppbefore, that is perhaps what I should go for? Regards stab. ---------------------------------------------------------------------- Giu · 2013-05-25 09:15 Quote from: stab on May 25, 2013, 10:48:19 amHi Giu, E:\download\customer1\test.exe is on the server. Am building the web-app using Raudus and have a structure with a download-dir per customer. The app allows me to display the content in a customers dir in a listbox for download selection. Haven't heard of XAMppbefore, that is perhaps what I should go for? Regards stab. Then you have tu publish this file in some way. I guess you need to serve this file from Raudus or some link (or something like this) in Apache if you use it. XAMPP is only a ready to go distribution for windows with Apache/MySQL/PHP I don't know about Raudus, is this working under apache? Check this link This way, you expose a folder, for example, using apache. in your example, you have to replace folders as you need, for example, something like: (I don't know if \ should be replaced with / or some others changes, I didn't tried, is only to show you an example) Code: [Select]Alias "/files" "E:\download\customer1"     AllowOverride None     Options Indexes     Order allow,deny     Allow from all This way, you (and anybody who knows the url) can access your file like: http://yourserver/files/test1.exe I hope I explained better. EDITED: Oh ok, I readed in your first post you are using apache. ---------------------------------------------------------------------- User137 · 2013-05-25 13:42 http://www.techrepublic.com/article/learn-how-to-configure- apache/5076696 There was some more info for sharing folders and files for apache. If you don't want to allow downloading test.exe, then you should enable the rights for specific files only, or make a separate subfolder for downloadable files, and then give permissions to that. ---------------------------------------------------------------------- stab · 2013-05-25 14:07 Thanks alot all for your guidance. I'll read documentation more and try your suggestions. Regards stab ---------------------------------------------------------------------- stab · 2013-05-30 13:39 Hi again, Tried to download to c:\Users\\Documents but no luck. Tried also to download to c:\temp\download that exists on my local machine but no luck. Downloading to c:\temp succeed, but data goes to webserver c:\temp. The code I'm using is like:       if HttpGetBinary(URL, response) then         response.SaveToFile(TargetFile); with httpsend, where TargetFile = c:\temp. There must be something I don't understand about using synapse httpsend and HttpGetBinary. Is there someone that can explain how to use it properly? Regards stab