Re: multipart form data
On Tue, 15 Jul 2003 at 17:30, Anshuman Kanwar opined: [snip] AK:So it sees the filename but not the data itself. Problem is that I want to AK:save the Jpg pictures in some other files and the AK:BOTZSERIAL=00:02:D3:00:01:01 type info in some other file, but I am not AK:seeing the binary (jpg) data at all. How do I extract the .jpg files from AK:this POST? you need to use upload() instead of param() to read the image. please read perldoc CGI for more information and examples. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
multipart form data
Hi all, I am trying to process a HTTP POST using CGI.pm (appended below). The encoding is multipart/form-data. One(or more) of these parts is(are) jpg images. I an curently dumping the name = value pairs using the following program: #!/usr/bin/perl -wT use strict; use CGI; my $q = new CGI; print $q-header( text/plain ); my( $name, $value ); open LOGFILE, /tmp/log || die(); foreach $name ( $q-param ) { print LOGFILE $name=; foreach $value ( $q-param( $name ) ) { print LOGFILE $value\n; } } close LOGFILE; This produces the following output : BOTZSERIAL=00:02:D3:00:01:01 ALERTPPIC_0=campic1.jpg ALERTPICTIME_0=984450623 ALERTPPIC_1=campic2.jpg So it sees the filename but not the data itself. Problem is that I want to save the Jpg pictures in some other files and the BOTZSERIAL=00:02:D3:00:01:01 type info in some other file, but I am not seeing the binary (jpg) data at all. How do I extract the .jpg files from this POST? Thanks, -ansh #-- POST /picalert HTTP/1.1 Authorization: Basic bmV0Ym90ejpwYXNzd29yZA== Host: 192.168.1.218:81 Content-Type: multipart/form-data; boundary=0193AAD31E8 User-Agent: NetBotz/1.1.3 Accept: */* Accept-Encoding: gzip Accept-Language: en --00193AAD31E8 Content-Disposition: form-data; name=BOTZSERIAL 00:02:D3:00:01:01 --00193AAD31E8 Content-Disposition: form-data; name=ALERTPPIC_0; filename=campic1.jpg Content-Type: image/jpeg {binary data for picture} --00193AAD31E8 Content-Disposition: form-data; name=ALERTPICTIME_0 984450623 --00193AAD31E8 Content-Disposition: form-data; name=ALERTPPIC_1;filename=campic2.jpg Content-Type: image/jpeg {binary data for picture} --00193AAD31E8 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
multipart/form-data Method POST to cgi script not working
Hello all, If anyone could shed some light on this I would be in there debt. I know what the BIG problem is...these scripts where written in perl5.004 and we have moved or are moving to 5.6.0, but I don't know where to start looking to fix the code so that is works with 5.6.0. This is a multipart/form-data form, using method POST I'm unable to retrieve the params passed to the cgi via $cgi-param('PARAM'), HOWEVER, if the method is GET the $cgi-param('PARAM') works, but GET is not supposed to work with multipart/form-data and doesn't in actually getting the file sent by the user via an upload script. I've even gone over the httpd.conf in hopes that it could be in there. Everything is install RPM, but I've also tried source with the same results. I will try to include everything that will be of help, but if I forget something just e-mail me and I'll get it for you. Thanks in advance, Chris # From rpm -qa apache-1.3.19-5 mod_perl-1.24_01-2 perl-5.6.0-12 # From the error_log after apache startup # Apache/1.3.19 (Unix) (Red-Hat/Linux) mod_ssl/2.8.1 OpenSSL/0.9.6 mod_perl/1.24_01 ApacheJServ/1.1.2 configured -- resuming normal operations # From perl -v ## This is perl, v5.6.0 built for i386-linux Copyright 1987-2000, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5.0 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using `man perl' or `perldoc perl'. If you have access to the Internet, point your browser at http://www.perl.com/, the Perl Home Page. This is for that application in httpd.conf ### ## Contract Underwriting test## Directory /path/to/the/dir/of/app Options Includes FollowSymLinks ExecCGI AllowOverride FileInfo AuthConfig Limit Indexes AuthName DBI AuthType Basic PerlAuthenHandler Apache::AuthenDBI PerlAuthzHandler Apache::AuthzDBI PerlSetVar Auth_DBI_data_source dbi:Oracle:something.something.tgic.com PerlSetVar Auth_DBI_usernamesomething PerlSetVar Auth_DBI_passwordsomething PerlSetVar Auth_DBI_pwd_table user_tbl PerlSetVar Auth_DBI_grp_table user_tbl PerlSetVar Auth_DBI_uid_field USER_NAME PerlSetVar Auth_DBI_pwd_field USER_PSWD PerlSetVar Auth_DBI_pwd_whereclause CU='Y' Limit GET POST order allow,deny allow from all require valid-user /Limit /Directory Location /app/path SetHandler perl-script PerlHandler Apache::Registry Options Includes FollowSymLinks ExecCGI /Location ## End Contract test## -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: multipart/form-data Method POST to cgi script not working
On Tue, 31 Jul 2001, mlists wrote: This is a multipart/form-data form, using method POST I'm unable to retrieve the params passed to the cgi via $cgi-param('PARAM'), HOWEVER, if the method is GET the $cgi-param('PARAM') works, but GET is not supposed to work with multipart/form-data and doesn't in actually getting the file sent by the user via an upload script. I've even gone over the httpd.conf in hopes that it could be in there. Everything is install RPM, but I've also tried source with the same results. I will try to include everything that will be of help, but if I forget something just e-mail me and I'll get it for you. The crucial thing you forgot to include is the actual code that is bombing. I see you are using CGI.pm, but are you using the actual multipart/form support in CGI.pm (using start_multipart_form)? -- Brett http://www.chapelperilous.net/btfwk/ And what will you do when you grow up to be as big as me? asked the father of his little son. Diet. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: multipart/form-data Method POST to cgi script not working
--- mlists [EMAIL PROTECTED] wrote: Here is the code, the HTML page that is a template that is merged with the %data hash handled by sub merge_template I've even wrote little test pages and scripts just to test the data passing and that is where i discovered the diff between POST and GET...i will send those too... During the post no data is passed to the cgii.e. $cgi-param('PARAM') = nothing test html ! html head titletest/title /head html body form enctype=multipart/form-data method=POST action=/apps/test1/test.cgi Select File: input TYPE=FILE NAME=FILE_TO_UPLOADbr Favorite color:input TYPE=TEXT NAME=FAVCOLORbr INPUT NAME=SUBMIT TYPE=SUBMIT VALUE=SUBMIT /form /body /html !!! test cgi ! #!/usr/bin/perl use CGI; $cgi = new CGI; $submit = $cgi-param('SUBMIT'); $fh = $cgi-param('FILE_TO_UPLOAD'); $fav = $cgi-param('FAVCOLOR'); open(UPLOAD, /tmp/fileuploadtest); while ($fh) { print UPLOAD; } close(UPLOAD); open(LOG, /tmp/test.log); print LOG $submit\n; #print LOG $file\n; print LOG $fav\n; close(LOG); print $cgi-header; print $cgi-start_html; print $submitbr; print $fhbr; print $favbr; print $cgi-end_html; I don't see any immediate problem (though maybe it's glaring and I'm just not getting enough coffee). Here's a test script you can try to verify that you're getting data sent: #!/usr/bin/perl -wT use strict; use CGI; use Data::Dumper; my $cgi = CGI-new; print $cgi-header, $cgi-start_html( 'CGI Test' ), $cgi-pre( Dumper $cgi ), $cgi-end_html; That will dump the CGI object to the screen. You'll see something like the following: $VAR1 = bless( { '.header_printed' = '1', '.charset' = 'ISO-8859-1', '.parameters' = [ 'color', 'name' ], '.fieldnames' = {}, 'name' = [ 'Ovid' ], 'color' = [ 'red' ] }, 'CGI' ); The '.parameters' will tell you the name of any parameters that were passed and later you can see the values associated with the individual parameters. It will also show you cookies, if available. They'll be in a CGI::Cookie object. Basically, if you get no .parameters, you know that the CGI object did not get any data. Cheers, Curtis Poe = Senior Programmer Onsite! Technology (http://www.onsitetech.com/) Ovid on http://www.perlmonks.org/ __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
CGI.pm not recognising multipart/form-data ?! help
I have an upload script that works fine on other servers, up i just reinstalled perl 5.6.1 on a new server and its not working in the same way CGI.pm is loaded and seemes to detect the value's of forms, but not form-data forms... Do i need to install a mod somewhere? Need help on this one quite badly :) Thanks in advance, Pierre