Hello,
I want to write a very simple server that will serve a couple of pages, one that receives an uploaded file from an HTML form, just like this:
<form method="post" action="
http://ares:55666/" enctype="multipart/form-data">
<input name="field1" type="text"><br />
<input type="file">
<input type="submit" value="enviar">
</form>
Also the other page will offer the received file and other simple pages for download. No need for https, the server will be deployed behind Apache, that will take care of that layer.
So I see that there're units in the FCL that seem to cover this functionality: fphttpserver and httpdefs. I wrote a handler for the OnRequest event like this:
Log(ARequest.DefaultRequestUploadDir);
Log('Uploaded files: ' + IntToStr(ARequest.Files.Count));
if ARequest.Files.Count > 0 then
Log(ARequest.Files[0].FileName);
AResponse.Content := '<html><head><title>test</title></head><body><h1>test</h1></body></html>';
AResponse.SendResponse;
The response gets sent fine, but the log shows 0 files and an empty default dir.
I guess that I can figure out the code (tracing it) but it would be a lot better if some kind soul could provide me with a minimal example that shows the file upload in action.
--
TIA,
Nico