#/usr/bin/perl -w use strict; use CGI; use DBI; #start our CGI object up my $Q = CGI->new(); #we probably want to set $CGI::POST_MAX, too. #initialize a DB handle my $dsn = 'username:host:password'; #see perldocs for exact form my $DBH = DBI->new( $dsn ); #check for a file my $file = $Q->param( 'uploaded_file' ); unless ( $file ) { #there is no file upload, so here's the form to do the upload print $Q->header(), $Q->start_html(), $Q->start_form(); print $Q->filefield( -name => 'uploaded_file' ); print $Q->end_html(); exit; } my $text = join( '', <$filename> ); #slurp the whole file up $DBH->do("INSERT INTO table VALUES( '$text' )"); #assumes blob or unicode text field in target table #status back to user print $Q->header(), $Q->start_hmtl, $Q->p( 'Done' ), $Q->end_html;