Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Have you checked the error.log of your server to see if there are any error conditions raised while it ran?

The only way i can see it not returning the print "<p><b>Name</b> -- $name<br><b>Email</b> -- $email<br><b>Comments</b> -- $comments<br>"; contents is if the cgi process terminated wit an error before reaching that point, like dieing because it cannot open the file.

To catch what would otherwise be a terminal error you can wrap the code in an eval block like so

eval { open (OUTFILE,">$upload_folder/$upload") or die $!;; binmode OUTFILE; while (<$upload_file>) { print OUTFILE; } close OUTFILE; }; print 'error:'.$@.'<br>' if $@;
the point made by pojabout use CGI::Carp 'fatalsToBrowser'; may serve to do the same thing. Or it may identify another error

ps, what do you think should be in $upload_file? what parm has the same name as of one of the files to be uploaded, not the value, its name.

consider

my @files = $q->param('multi_files'); my @io_handles=$q->upload('multi_files'); foreach my $upload(@files){ print "Upload this please -- $upload<br>"; my $upload_file = shift @io_handles; if ($upload_file){ eval { open (OUTFILE,">$upload_folder/$upload") or die $!;; binmode OUTFILE; while ( my $bytesread = $upload_file->read($buffer,1024) ) { print OUTFILE $buffer; } close OUTFILE; }; print 'error:'.$@.'<br>' if $@; } else { print "<b>Guess it's broken</b><br/>"; } }
see http://search.cpan.org/~leejo/CGI-4.35/lib/CGI.pod#Processing_a_file_upload_field

you may also be interested in

my $type = $q->uploadInfo( $upload_file )->{'Content-Type'};
To determine if you need binmode and should use read, or if you dont want binmode and can use <$upload_file>


In reply to Re: CGI, uploading multiple files by huck
in thread CGI, uploading multiple files by edimusrex

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2021-12-01 17:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (13 votes). Check out past polls.

    Notices?