> My question is if anyone has any samples of code on how to
> properly handle a
> POST form submition that contains a binary file.  Then how to insert this
> data into Mysql through perl/DBI module.

hi,

recently i wrote some script that uploads solutions
to perl excercises for a class i'm teaching. as i have
quite a few students this semester i do some on the fly
compression of the data i get from the script with
compress::zlib.

hope you find this helpful,

a.

...

my $file=$cgi->upload("script");

...

while(read $file,$data,1024){
    $output=compress($data);
    push(@src,$output);
}

write2db([EMAIL PROTECTED]);

sub write2db{
    my $data=shift;
    my @[EMAIL PROTECTED];
    my
$dbh=DBI->connect("dbi:mysql:db","user","passwd",{PrintError=>0,RaiseError=>
1});
    foreach(@data){
        my $quoted_line=$dbh->quote($_);
        $dbh->do("INSERT INTO sources VALUES($quoted_line)") or die $!;
    }
    $dbh->disconnect;
}

Reply via email to