Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: CGI File Upload Problems

by randyk (Parson)
on Apr 04, 2007 at 04:44 UTC ( #608203=note: print w/replies, xml ) Need Help??

in reply to CGI File Upload Problems

The following:
use strict; use warnings; use CGI; use CGI::Carp qw/fatalsToBrowser/; my $q = CGI->new(); print $q->header(), $q->start_html("File Upload Example"); # Start a multipart form. print $q->start_multipart_form(), "Enter the file to process: ", $q->filefield('filename','',25), $q->br, $q->reset, $q->submit('submit','Process File'), $q->endform; # Process the form if there is a file name entered if (my $file = $q->upload('filename')) { my $tmpfile=$q->tmpFileName($file); my $txt; while (<$file>) { $txt .= $_; } close($file); print $q->hr(), $q->h2($file), $q->h3($tmpfile), $q->p, $txt; } print $q->hr(), $q->end_html;
works for me, even for files that have a comma or & in their names. Does this also exhibit a problem for you? Perhaps there's something going wrong at the stage of writing to the local file?

Replies are listed 'Best First'.
Re^2: CGI File Upload Problems
by jupe (Beadle) on Apr 04, 2007 at 19:03 UTC
    well, your code works just fine, and mine doesn't. at least that's something (nothing is completely broken)--thanks for your help, i think i will be able to get it fixed!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2021-02-25 00:08 GMT
Find Nodes?
    Voting Booth?

    No recent polls found