title: Save image as a blob type
body: <p>I have used MySQL to save a image as a blob type. I 'm uploading files through PHP and when I get the image back I revive only a part of it. How can I improve the max size ? (my image file size is less than 300 KB)</p>
  
  <p>PHP uploader...</p>
  
  <pre><code>if($_FILES!=null &amp;&amp; $_POST!=null){
      $file = $_FILES["image"]["tmp_name"];   
  
      if(!isset($file)){
          echo "Please upload an image";
      }else{
          $image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
  
          $image_name = addslashes($_FILES['image']['name']);
          $type=$_POST['type'];
  
          $image_size = getimagesize($_FILES['image']['tmp_name']);
  
          if($image_size==FALSE)
              echo "That's not an image.";
          else
          {
  
              if(!(mysql_query("INSERT INTO store (name,image,type) values  ('$image_name','$image','$type')")))
                  echo "Problem uploading image";
              else
              {
                  $lastid = mysql_insert_id();
                  echo "Image uploaded. &lt;p /&gt; Your image: &lt;p /&gt; &lt;img id='imageId' src=get.php?id=$lastid&gt;";
              }
          }
      }
    }
  </code></pre>
  
  <p>retrieving image</p>
  
  <pre><code>$id = addslashes($_REQUEST['id']) ;
  
  $imageRow = mysql_query("SELECT * FROM store WHERE id=$id");
  
  $image = mysql_fetch_assoc($imageRow);
  $image = $image['image'];
  
  header("Content-type: image/jpg");
  
  
  echo $image;
  </code></pre>