corneliusdavid 214 Posted July 4, 2021 I've got a small WebBroker application that requests the user to choose a file which is then posted to another page of the WebBroker application. The web form's HTML is like this: <form action="UploadFile" method="post" enctype="multipart/form-data"> <label for="MyFile">Select file to upload:</label><br /> <input type="file" id="MyFile"> <button type="submit">Upload</button> </form> The TWebApplicationItem that handles the "/UploadFile" path is trying to get the file to upload so it can save it on the server but I can't find documentation or an example of how to do this. I've tried looking at both TRequest.ContentFields and TRequest.Files properties but they're always empty. I found an old StackOverflow question relating to this that mentioned including the ReqMulti unit so that it parses the multi-part form but that didn't fill the Files property for me. Finally, I called Request.ExtractContentFields but it just gave me the same raw string, ('------WebKitFormBoundaryBRM3RcInbYBqzsVj--') that I saw in the TRequest.Content property. From what I've been reading, I should be able to create a TFileStream and somehow use the Content property to read the file from the headers but I'm not sure how to get the file information. Can someone point me in the right direction? Share this post Link to post
corneliusdavid 214 Posted July 6, 2021 Re-reading the StackOverflow question and looking more closely at my HTML, I realized I was missing the name attribute in the input element. Now my Files property is being filled and I can save the uploaded file. 🙂 <form action="UploadFile" method="post" enctype="multipart/form-data"> <label for="MyFile">Select file to upload:</label><br /> <input type="file" id="MyFile" name="MyFile"> <button type="submit">Upload</button> </form> Share this post Link to post