I'm using Delphi as a server to serve a number of different requests. All that are simple strings works fine, but I have some trouble recieving files.
All are implemented using a Webbroker service, so I get a method
WebModule1WebActionItem1Action(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
I have a /test method, with type=mtPost.
Inside of the action, I do the following:
MimeType := Request.ContentFields.Values['MimeType'];
for i := 0 to Request.Files.Count-1 do begin
// never entered
aFile := Request.Files.Items[i];
ms := TMemoryStream.Create;
aFile.Stream.Position := 0;
ms.CopyFrom(aFile.Stream, aFile.Stream.Size);
ms.SaveToFile(path+aFile.FileName);
ms.free;
end;
Apparently whatever I send is never recognized as files, but I dont know why. The HTML used to post, looks like this:
<form id="myForm" action="http://localhost:8080/test" method="post" enctype="multipart/form-data">
<input type="file" size="60" name="myfile">
<input type="text" size="10" name="mimetype" value="image/hest">
<input type="submit" value="upload">
</form>
I'd appriciate anybody telling me what could be wrong - and how to solve it. Basically I just need to be able to recieve 1 file at the time, including the mimetype (because I need to return it when I serve the file later)