miggel15 has asked for the wisdom of the Perl Monks concerning the following question:
And now, I want to insert the file in a mysql database (blob field). Here is the upload_process script:<form action="upload_process.pl" method="post" enctype="multipart/form +-data"> <input type="file" name="myfile" accept="text/*" maxlength="2097152"> <!-- hier beliebige andere Felder --> <input type="submit" value="RESSOURCE" name="action"><input type="rese +t"> </form>
And here is the insert function:... my $q = new CGI; my $file = $q->param("myfile"); binmode $file; &insertRessource( $name, $entryid, $file, $mime ); #all parameters are available
This code is working but - sadly - not correct ;) I can see blob-data in the binary field but it contains only the filename of the uploaded document (about 7 Bytes). Can anybody help me? Thanks miggel15sub insertRessource { my $name = $_[0]; my $entryid = $_[1]; my $file = $_[2]; my $mime = $_[3]; my $sth = $dbh->prepare('insert into ressource (name, entryID ,dat +a, mime) values (?,?,?,?)'); $sth->execute($name, $entryid, $file, $mime) or die $!; $sth->finish; $dbh->disconnect; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to manage post binary upload with mysql blob fields
by Anonymous Monk on Feb 15, 2011 at 07:58 UTC | |
by miggel15 (Initiate) on Feb 15, 2011 at 09:11 UTC | |
by poj (Abbot) on Feb 15, 2011 at 20:52 UTC | |
|
Re: How to manage post binary upload with mysql blob fields
by locked_user sundialsvc4 (Abbot) on Feb 15, 2011 at 14:36 UTC |