relax99 has asked for the wisdom of the Perl Monks concerning the following question:


I was wondering if anyone had any experience with CGI::Minimal. I have been using it as a light-weight alternative to to retrieve form data (I do not need HTML generating capabilities of since using templates is a more maintainable solution in most cases anyway).

I've been trying to get CGI::Minimal to work with file-upload forms, but it does not seem to work at all. As soon as I add enctype="multipart/form-data" to my form tag, my script that uses CGI::Minimal never finishes. I know the problem is in CGI::Minimal, because and direct read from STDIN work just fine. I've searched newsgroups for any clues, and I am somewhat surprised that no one had ever noticed that CGI::Minimal does not work for form-based file uploads, even though it claims to.

Do you think CGI::Minimal is buggy, or could it be something else? I would appreciate any hints.

Thank you,

  • Comment on CGI::Minimal does not work with enctype="multipart/form-data"?

Replies are listed 'Best First'.
Re: CGI::Minimal does not work with enctype="multipart/form-data"?
by valdez (Monsignor) on Oct 18, 2002 at 16:16 UTC

    Hi relax99,
    CGI::Minimal works for me. Here is a minimal :) example:

    #!/usr/bin/perl use strict; use warnings; use CGI::Minimal; my $cgi = CGI::Minimal->new; if ($cgi->param('uploading')) { print "Content-type: ", $cgi->param_mime('thing'), "\r\n\r\n"; print $cgi->param('thing'); } else { print "Content-type: text/html\r\n\r\n"; print q{ <html><body> <form action="/cgi-bin/myup.cgi" method="post" enctype="multipart/fo +rm-data"> <input type="hidden" name="uploading" value="yes"> <input type="file" name="thing" size="16"><br> <b><input type="submit" value=" Upload "></b> </form> </body></html>}; } exit;

    It was not clear from the man page that param_filename(...) is only for retrieving the filename and that we should use param(...) to get file content...

    Ciao, Valerio

      Thanks a lot for the example! I had something similar in my code, but I did make another script file with what you gave me and it still didn't run :( Are you using a Unix system? I'm on Windows 2000. I'm wondering if that's why I'm having problems, but then why does work just fine for me?

      I could only get CGI::Minimal to finish running if I set CGI::Minimal::max_read_size to no more than 300 bytes, but then the script obviously doesn't read the entire content of the form.

      I don't like to give up on anything, but in this case it seems CGI::Minimal just has problems and I'm not sure I want to spend too much of my time on it. Sounds like I need to switch back to

        You are welcome :) I'm using a Linux system, with CGI::Minimal version 1.09 and perl v5.6.0. And you? Can you post some code?

        Ciao, Valerio

Re: CGI::Minimal does not work with enctype="multipart/form-data"?
by strredwolf (Chaplain) on Oct 19, 2002 at 01:58 UTC
    There was a CGI::Lite module out there that was advertized in The Linux Journal. Maybe that'll help out, since it strips out the HTML generation side.


Re: CGI::Minimal does not work with enctype="multipart/form-data"?
by MZSanford (Curate) on Oct 18, 2002 at 15:26 UTC
    My guess is that CGI::Minimal was written without support for file uploads, as they are somewhat complex, and not terribly minimal
    from the frivolous to the serious

      CGI::Minimal documentation says:

      Rather than attempt to address every possible need of a CGI programmer, it provides the _minimum_ functions needed for CGI such as form decoding (including file upload forms), URL encoding and decoding, HTTP usable date generation (RFC1123 compliant dates) and _basic_ escaping and unescaping of HTMLized text.

      I am rather confused by "functions ... for ... file upload forms". Should I just assume it does NOT support it?