Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

by valdez (Monsignor)
on Oct 18, 2002 at 16:16 UTC ( #206345=note: print w/replies, xml ) Need Help??


in reply to CGI::Minimal does not work with enctype="multipart/form-data"?

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

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

Replies are listed 'Best First'.
Re: Re: CGI::Minimal does not work with enctype="multipart/form-data"?
by relax99 (Monk) on Oct 21, 2002 at 11:45 UTC

    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 CGI.pm 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 CGI.pm

      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

        I'm using CGI::Minimal version 1.09. I used ppm to install it, just tried reinstalling it - didn't help. My perl is ActiveState distribution (v5.6.1 built for MSWin32-x86-multi-thread). I'm using a Windows 2000 Professional system with IIS webserver installed on it.

        I have just tried running the code you gave me - still doesn't finish. And below is the code I used for tests before:

        To test file upload using CGI.pm - successful

        # to test form upload using CGI.pm - works fine! use strict; use warnings; use CGI; my $cgi = CGI->new; print "Content-Type: text/html\n\n"; print "<body><html>\n"; my $fh = $cgi->upload("file1"); print <$fh>; print "</body></html>\n"; exit(0);

        To test file upload using CGI::Minimal - does't work!

        # to test form upload use strict; use warnings; use CGI::Minimal; my $cgi = CGI::Minimal->new; print "Content-Type: text/html\n\n"; print "<body><html>\n"; print $cgi->param("file1"); print "</body></html>\n"; exit(0);

        Below is html for the form

        <html> <head> <title>CGI::Minimal test</title> </head> <body> <form enctype="multipart/form-data" action="/cgi-bin/upload.pl" method +="post"> <input type="file" name="file1"> <input type="submit" value="Submit"> </form> </body> </html>

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://206345]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2021-05-07 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (91 votes). Check out past polls.

    Notices?