title: How to store image in database
body: <p>I am trying to insert image in database. The database has a field named <code>images</code> and its type is BLOB. I am trying to insert the image, but only the first 2.2KB is stored. Even if I insert another image it stores only 2.2KB in the database. </p>
  
  <p>When I try to show this image in my application it doesn't show; it's just a small icon, not the image. How can I insert the image in the right way?</p>
  
  <pre><code>use CGI;  
  my $file = $q-&gt;param("file"); 
  $file = 'C:/wamp/bin/apache/apache2.2.22/cgi-bin/images/2.jpg';
  open(my $fh, $file);
  my $data;
  binmode($fh);
  read($fh, $data, (stat($fh))[7]);
  close($fh);
  
  my $Data = {
          table    =&gt;'student',
          data     =&gt; {    
          Image    =&gt; $fh,
          }       
  };
  
  Data::Insert($Data);
  
  print $q-&gt;header;
  print $q-&gt;start_html(
     -title =&gt; "student",
  );
  
  print $q-&gt;end_html;
  </code></pre>
  
  <p>showImage.pl</p>
  
  <pre><code>my $q = new CGI();
  my $handle = Dbm::connection();
  
  $id = $q-&gt;param('id_person');
  
  $getimage = $handle-&gt;selectrow_array (&lt;&lt;SQLEOF); 
      SELECT Image
        FROM student  
      WHERE ID  = '$id'
  SQLEOF
  
  print "Content-Type: image/jpeg\n";
  print "Content-length: \n\n";
  
  binmode STDOUT;
  print STDOUT $getimage;
  </code></pre>