CGI to upload files lazarus / 8-Other ---------------------------------------------------------------------- leocda · 2008-09-26 13:52 I'm trying to do a raw CGI to read a file upload form. The upload is big, kind of 1mb. I wanna make it in pascal. I don't want answers like: "you can do that with xxxxxxx library". They don't help in fact. I'm looking for EXAMPLES that really work. Does anybody there has one?     Thanks. ---------------------------------------------------------------------- bee · 2008-09-26 14:37 For CGI web programming, you may use FPC/Laz's CGI framework, you may find it on your FPC/Laz installation folder. Or, you may use Powtils CGI API. I'm using the last. It works, and works very well. ---------------------------------------------------------------------- leocda · 2008-09-27 07:13 Powtils looks very complete. It's nice, but since it deals with every single point about HTTP, it's sub-optimal for several operations. I needed it as fast and direct as possible, so I decided to make it by myself. In fact, it's easy. If you spend a few time getting deeper in HTTP, so you make a raw cgi to upload files from scratch with less than 100 code lines.         Thanks. ---------------------------------------------------------------------- bee · 2008-09-27 13:59 What do you mean by "it deals with every single point about HTTP"? Which operation it doesn't do the job optimally? Can you share your code? So someone, particularly the Powtils people, could take the benefit from your indirect contribution. ---------------------------------------------------------------------- leocda · 2008-09-27 20:50 I see you didn't understand, so I will explain. A complete http solution need to have a parser for all the request content, and prepared for all possibilties. It need to be able to split the content in a list of "fields", so split each field in its metadata and the proper data. So it needs to parse the metadata and, depending on the values, still need to take some care about the field data itself. And I'm just talking about the POST method. The other ones are kind of different about the parsing way. Since my case is very specific, I could code just what really matters for me, what of course is much faster cause I know exactly what my request looks like without parsing. If you still don't understand, maybe could be nice for you study the HTTP protocol.        Best regards. ---------------------------------------------------------------------- bee · 2008-09-28 09:30 Ah, I see. Of course, Powtils or any other general purpose frameworks/components/etc would do "every single point about its purpose" since it would like to serve any kind of possible operations within the purpose. If you don't like the "general" approach, nobody would prevent you to code your own specific and specialized purpose. But once you need to enhance/expand your code, you might want to consider the general approach provided by other frameworks, or you'll end up writing everything by your own hand (reinvent the wheel?). Nice to hear you had overcome your problem. Good luck!