Yaron 53 Posted June 16, 2019 I am trying to upload an image from an html form (see below) to a MARS server. Previously, I was able to get this working when the client was written in Delphi, but now the client is a standard browser and the code fails (LParam.isFile returns false). HTML form: <form method="post"> <input type="text" name="ImageName" required><br> <input type="file" accept="image/jpeg" name="ImageFile" required> </form> The code I used to get the image that doesn't seem to work in this case : var lParam : TFormParam; mStream : TMemoryStream; begin For lParam in aParams do Begin If (SameText(lParam.FieldName, 'ImageFile')) then Begin If (LParam.isFile) then Begin mStream := TMemoryStream.Create; mStream.Write(lParam.AsFile.Bytes,Length(lParam.AsFile.Bytes)); mStream.Position := 0; Try mStream.SaveToFile('d:\test.jpg'); Finally mStream.Free; End; End; End; end; Any ideas? Share this post Link to post
Yaron 53 Posted June 16, 2019 (edited) I believe that I solved this issue, I was missing enctype="multipart/form-data" in the form's statement. Edited June 16, 2019 by Yaron Share this post Link to post
Andrea Magni 75 Posted June 17, 2019 Hi, yes the HTML form should be a multipart/form-data one... Glad you solved 😉 Sincerely, Andrea Share this post Link to post