File Upload

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::pOST_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
 
B

Brian McCauley

(e-mail address removed) wrote:

[ Exaclty the same as he did in clp.modules ]

Please don't do that. Multiposting like this is almost never
justified.

Genuine cross-posting is sometimes justfied but given that the clp.misc
charter says that its for stuff that doesn't doesn't fit elsewhere in
clp.* cross-posting clp.misc and any other clp.* group is generally
inapproriate.

Please do not contribute to this thread - see the one in clp.modules.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,060
Latest member
BuyKetozenseACV

Latest Threads

Top