gilbert has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use CGI qw(:standard); print header(),start_html('Upload Files'); print start_multipart_form(); print h2('Upload Files'); print "Select the File: ", filefield(-name=>'filepath', -size=>30, -maxlength=>100), p, reset, submit('submit', 'Upload File'); print end_form(); if (my $filehandle = param('filepath')) { doUpload(); } else { print "Choose a file to upload"; } sub doUpload { my ($bytes, $buffer, $bytesread); my $filehandle = CGI::param('filepath'); open OUTFILE, '>$filehandle' or die "Couldn't open output file: $!\n"; while ($bytes = read($filehandle, $buffer, 1024)){ $bytesread += $bytes; print OUTFILE $buffer; } warn "Recieved $bytesread bytes"; close OUTFILE; } print end_html;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: need help with file uploading
by stephen (Priest) on Jun 19, 2001 at 22:39 UTC |