title: mysqli image blob insert not working
body: <p>I'm trying to upload an image file to my MySql Database. I've already seacrh on the web and I finally start using the following script:</p>
  
  <pre><code>if(is_uploaded_file($_FILES['filename']['tmp_name'])){
  
  $maxsize=$_POST['MAX_FILE_SIZE'];       
  $size=$_FILES['filename']['size'];
  
  // getting the image info..
  $imgdetails = getimagesize($_FILES['filename']['tmp_name']);
  $mime_type = $imgdetails['mime']; 
  
  // checking for valid image type
  if(($mime_type=='image/jpeg')||($mime_type=='image/gif')||($mime_type=='image/png')){
    // checking for size again
    if($size&lt;$maxsize){
      $filename=$_FILES['filename']['name'];  
      $imgData =addslashes (file_get_contents($_FILES['filename']['tmp_name']));
  
           if(is_uploaded_file($_FILES['filename']['tmp_name'])){
               debug('subida ok');
           }else{
               debug('fallo subida');
           }
  
          //echo $imgData;
          $imgDetail=addslashes($imgdetails[3]);
  
  
          $db = new mysqli('127.0.0.1','user','pass', 'db');
          if($db-&gt;connect_error){
              debug('Error en la conexion : '.$db-&gt;connect_errno.
                                         '-'.$db-&gt;connect_error);
          }
  
          $stmt = $db-&gt;stmt_init();
          $stmt-&gt;prepare("INSERT INTO `image` (`name`, `image`, `type`, `size`) VALUES (?, ?, ?, ?)");
          if($stmt===false){ debug('Error en prepare');}
          $rc=$stmt-&gt;bind_param('sbss', $filename, $imgData, $mime_type,$imgDetail);
          if($rc===false){ debug('Error en bind');}
          if($stmt-&gt;execute()==false){ debug('error ' . $stmt-&gt;error); };
          $stmt-&gt;close();
  
  
    }else{
      debug("&lt;font class='error'&gt;Image to be uploaded is too large..Error uploading the image!!&lt;/font&gt;");
    }
  }else{
    debug("&lt;font class='error'&gt;Not a valid image file! Please upload jpeg or gif image.&lt;/font&gt;");
  }
  
  }else{          
    switch($_FILES['filename']['error']){
  case 0: //no error; possible file attack!
    debug("&lt;font class='error'&gt;There was a problem with your upload.&lt;/font&gt;");
    break;
  case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
    debug( "&lt;font class='error'&gt;The file you are trying to upload is too big.&lt;/font&gt;");
    break;
  case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
    debug( "&lt;font class='error'&gt;The file you are trying to upload is too big.&lt;/font&gt;");
    break;
  case 3: //uploaded file was only partially uploaded
    debug( "&lt;font class='error'&gt;The file you are trying upload was only partially uploaded.&lt;/font&gt;");
    break;
  case 4: //no file was uploaded
    debug( "&lt;font class='error'&gt;You must select an image for upload.&lt;/font&gt;");
    break;
  default: //a default error, just in case! 
    debug( "&lt;font class='error'&gt;There was a problem with your upload.&lt;/font&gt;");
    break;
    }     
  }   
  </code></pre>
  
  <p><strong>Uploaded image seems to be find taking in care script output but looking at the database size is 0 bytes...
  Does anybody knows why this?</strong></p>