[AGREED] processing web forms using mod_pascal is OK, but file-upload is fail lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- ADMGNS · 2025-06-07 00:40 hello i,m trying to understand the behind of cgi mechanism from ground with mod_pascal.. i,ve challenged most of things, but, excep file upload.. how client side sends file data while uploading via web forms?? and how i can handle this streaming data using pascal (via mod_pascal)? thanks ---------------------------------------------------------------------- Leledumbo · 2025-06-09 17:21 Quote from: ADMGNS on June 07, 2025, 02:40:06 amhow client side sends file data while uploading via web forms?? Here's the partial raw data of such request: Code: [Select]Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266 Content-Length: somenumber -----------------------------9051914041544843365972754266 Content-Disposition: form-data; name="file1"; filename="a.txt" Content-Type: text/plain Content of a.txt. -----------------------------9051914041544843365972754266 The content of the uploaded file will be after the Content-Type and before the boundary, both of which have empty lines between the content. Quote from: ADMGNS on June 07, 2025, 02:40:06 amand how i can handle this streaming data using pascal (via mod_pascal)? Should be the same as in other fcl-web backends, read my tutorial. Just ensure in either httpd.conf / apache2.conf (no idea what your Apache distribution uses), you have LimitRequestBody set to a reasonable number which can be inside , , or block. The default is 0 (unlimited), but this can vary from distribution to distribution. Sometimes it's implicitly overriden via mod_security, so be sure to check that one out. ---------------------------------------------------------------------- zamronypj · 2025-06-09 22:29 To tell browser that you are sending file upload, add attribute enctype="multipart/form-data"  Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i
...
To read uploaded file, you need to read request body from STDIN, but you need to parse multipart/form-data yourself and read binary data of file content. Read RFC 7578 https://datatracker.ietf.org/doc/html/rfc7578 for more information. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses    sysutils; var    contentLen : integer;    requestBody : string;    ch : char;begin    writeln('Request body:');    contentLen := strToInt(getEnvironmentVariable('CONTENT_LENGTH'));    if contentLen <> 0 then    begin        requestBody := '';        repeat            read(ch);            requestBody := requestBody + ch;            dec(contentLen);        until contentLen = 0;        writeln(requestBody);    end;end. ---------------------------------------------------------------------- ADMGNS · 2025-06-10 02:04 hello there thank you for your kind replies.. "streaming data" means, when we trying upload very big files, is incoming data. i mean, does the client send partial data of file or whole file at once ? regs ---------------------------------------------------------------------- Leledumbo · 2025-06-10 05:19 Quote from: ADMGNS on June 10, 2025, 04:04:41 am"streaming data" means, when we trying upload very big files, is incoming data. i mean, does the client send partial data of file or whole file at once ? All options are possible, depending on the server. If they allow unlimited connection time, whole file at once is possible. Otherwise, there are three options for partial uploading: Transfer-Encoding: chunkedS3 style multipart uploadWebSockets / gRPCThe first one is standardized. You just sent chunks until the closing chunk (0\r\n\r\n). The second one is an application level protocol, which means the server must be coded specifically to handle this. The common flow is: Client initiate request, supplying filenameServer responds with an IDClient hits multiple requests, each representing a part of the file, supplying part number and the ID from the responseServer responds with another ID, usually an ETag, for each successfully uploaded partClient completes the request by sending an XML request with a part number - ETag pair, for confirmationServer constructs the complete file based on the XML information and send response with whatever considered usefulOf course you can omit the completion request, stating the number of parts at the initial request, or maybe change the XML to JSON, works, too. It's application level, meaning you're in control. The third and the last one is like a pure socket, the protocol is bidirectional so through the same "tunnel" you can pass data as you wish continuously. Each has different implementation, though, so feel free to read and understand how each works. ---------------------------------------------------------------------- ADMGNS · 2025-06-11 00:00 thank you for your informative and clarify reply (or may i say response i,m always wondering how some file-sharing sites implement these mechanisms to upload very big files, for example, megaupload, wetransfer, etc.. because, in my experiments, upload operations fail and raise timeout error generally at server-side or sometimes at client-side.. so.. i must study hard and deeply a bit on kind topics and some details.. the fact that, in order to fully learn something, you have to sit down and do it all over again from ground.. on other ways, it always remains unexpected gray zones.. regs ---------------------------------------------------------------------- Leledumbo · 2025-06-13 02:28 Quote from: ADMGNS on June 11, 2025, 02:00:52 ami,m always wondering how some file-sharing sites implement these mechanisms to upload very big files, for example, megaupload, wetransfer, etc.. because, in my experiments, upload operations fail and raise timeout error generally at server-side or sometimes at client-side.. You can always inspect what happens under the hood by opening your browser's developer tools, navigate to the Network tab, then do the big file upload. The request will be logged where you can inspect what's being sent and received. ---------------------------------------------------------------------- ADMGNS · 2025-06-16 03:28 hello i know, i know that tools, of course.. even i use that tools to catch "undownloadable" video links, for example, WA status videos etc but, there are lots of sub-items, not only classic links but also dynamic elements, like workers, wasm, xhr, js, redirections, sockets, and new media streaming protocols, etc.. ie, it is too complex, like a tangle of hair.. after for a while, you lost your paths, your tips.. thanks, regs