K
kalikoi
Hi
I'm using the following code for PDF file upload via perl
The code is working.
but the file size is zero bytes
any suggestions
#!/usr/local/bin/perl -w
####### Load Needed Perl Modules ######
use strict;
# Make HTML/FORMS/UPLOADING easy to deal with
use CGI;
# Report errors in the browser
use CGI::Carp 'fatalsToBrowser';
# Limit file size
$CGI:OST_MAX=500000; # max 100K posts
####### End Perl Module Load #######
# Create new CGI object
my $q = new CGI;
if ( $q->param() ) {
# read filehandle from param and set to binary mode
my $filehandle = $q->param('proof_file');
binmode($filehandle);
# Strip off WINDOZE path crap
$_=$filehandle;
s/.*\\//;
my $filename=$_;
# open file for output - change this to suit your needs!!!
open(OUT,">upload/$filename") || die $!;
binmode(OUT);
# process $filehandle
{
my $buffer;
while ( read($filehandle,$buffer,500000) ) {
print OUT $buffer;
}
}
# close output file
close(OUT);
# show success
print $q->header,
$q->start_html,
$q->p('File uploaded: $filename'),
$q->end_html;
exit(0);
}
Thanks & Regards
kalyan kamesh
I'm using the following code for PDF file upload via perl
The code is working.
but the file size is zero bytes
any suggestions
#!/usr/local/bin/perl -w
####### Load Needed Perl Modules ######
use strict;
# Make HTML/FORMS/UPLOADING easy to deal with
use CGI;
# Report errors in the browser
use CGI::Carp 'fatalsToBrowser';
# Limit file size
$CGI:OST_MAX=500000; # max 100K posts
####### End Perl Module Load #######
# Create new CGI object
my $q = new CGI;
if ( $q->param() ) {
# read filehandle from param and set to binary mode
my $filehandle = $q->param('proof_file');
binmode($filehandle);
# Strip off WINDOZE path crap
$_=$filehandle;
s/.*\\//;
my $filename=$_;
# open file for output - change this to suit your needs!!!
open(OUT,">upload/$filename") || die $!;
binmode(OUT);
# process $filehandle
{
my $buffer;
while ( read($filehandle,$buffer,500000) ) {
print OUT $buffer;
}
}
# close output file
close(OUT);
# show success
print $q->header,
$q->start_html,
$q->p('File uploaded: $filename'),
$q->end_html;
exit(0);
}
Thanks & Regards
kalyan kamesh