monkfan has asked for the wisdom of the Perl Monks concerning the following question:
However when I tried to capture the result. Although it can identify the file name, but it cannot identify it's value.# Problematic Upload Entry strong('Choose File to upload: '), filefield(-name=>'upload',-size=>60),br,
The error message given by the problematic line 55 is:my $file = param('upload'); # This line print successfully print h2('File name'), $file; # But not the subsequent lines # Line 55 begins here print h2('File MIME type'), uploadInfo($file)->{'Content-Type'}; while (<$file>) { print; $length += length($_); } print h2('File length'), $length;
Furthere more if you comment out the uploadInfo($file)->{'Content-Type'} line. The content inside while loop doesn't get printed.Can't use an undefined value as a HASH reference at /home/ewijaya/publ +ic_html/MyTest/cgi-bin/price_debug.cgi line 55.
And it can be tested through this link.#!/usr/bin/perl -w use strict; use CGI qw/:standard :html3/; use CGI::Carp qw( fatalsToBrowser ); print header, start_html('Order Ice Cream with Price'), h1('Order Ice Cream with Price'); generate_form(); print_results(); sub generate_form { print hr, start_form, strong('Your email: '), textfield( -name => 'user_email' ), br, br strong('Cone: '), radio_group( -name => 'cone', -multiple => 1, -values => [qw/sugar waffle/] ), br, br strong('Number of Units: '), textfield( -name => 'no_unit' ), br, br # Problematic Upload Entry strong('Choose File to upload: '), filefield(-name=>'upload',-size=>60),br, + submit( -value => 'Submit' ), end_form, hr; } sub print_results { print "You ordered ", param('no_unit'), ' unit of ', param('cone'), ' cone.'; print br; my $ct = param('cone'); my $nu = param('no_unit'); my $uemail = param('user_email'); my $length; my $file = param('upload'); # This line print successfully print h2('File name'), $file; # But not the subsequent lines print h2('File MIME type'), uploadInfo($file)->{'Content-Type'}; while (<$file>) { print; $length += length($_); } print h2('File length'), $length; print br; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problematic UploadFile() method in CGI.pm
by wfsp (Abbot) on May 20, 2006 at 19:16 UTC | |
|
Re: Problematic UploadFile() method in CGI.pm
by ioannis (Abbot) on May 20, 2006 at 20:08 UTC | |
by Errto (Vicar) on May 21, 2006 at 17:02 UTC | |
|
Re: Problematic UploadFile() method in CGI.pm
by gellyfish (Monsignor) on May 21, 2006 at 10:38 UTC | |
|
Re: Problematic UploadFile() method in CGI.pm
by ahmad (Hermit) on May 21, 2006 at 10:26 UTC |