Hello everybody,
in short words: I want to upload a binary data with a html form, handle it with a perl script and store it in a mysql blob field. I have created an upload-form with html:
<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 now, I want to insert the file in a mysql database (blob field). Here is the upload_process script:
... my $q = new CGI; my $file = $q->param("myfile"); binmode $file; &insertRessource( $name, $entryid, $file, $mime ); #all parameters are available
And here is the insert function:
sub 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; }
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 miggel15

In reply to How to manage post binary upload with mysql blob fields by miggel15

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.