title: Upload images with thumbnails to folder and add path to Mysql
body: <p>I am willing to add or update images with auto thumbnails to folder and add path to MySQL database. I tried this code with this. I am able to upload images to folder and saving path to database but I can't able to generate thumbnails please help me on this. </p>
  
  <pre><code>&lt;?php
  ob_start(); 
  include('include/connect.php'); 
  if(isset($_GET['id']))
  {
      $qry = "SELECT * FROM tbl_emp where id=".$_GET['id'];
      $result = mysql_query($qry);
      $row = mysql_fetch_array($result);
  
      if($_SERVER["REQUEST_METHOD"] == "POST")
      {
          $name = $_POST["name"];
          IF($_FILES['file']['name']!='')
          {
               $file='uploads/'.$row['image'];
               $thumbs='uploads/thumbs/'.$row['image'];
               @unlink($file);
               $tmp_name = $_FILES["file"]["tmp_name"];
               $namefile = $_FILES["file"]["name"];
               $ext = end(explode(".", $namefile));
               $image_name=time().".".$ext;
               $fileUpload = move_uploaded_file($tmp_name,"uploads/".$image_name);
               $Uploadthumbs = move_uploaded_file($tmp_name,"uploads/thumbs/".$image_name);                
          }
          else
          {
              $image_name=$row['image'];
          }
  
           $sqlAdd ="update  tbl_emp set name='".$name."', image='".$image_name."'  where id=".$_GET['id'];
           mysql_query($sqlAdd);
           header("Location:add.php?id=".@$_GET['id']."&amp;msg=success");
           exit;
      }       
  }
  else
  {
      if($_SERVER["REQUEST_METHOD"] == "POST")
      {
          $name = $_POST["name"];
          IF($_FILES['file']['name']!='')
          {
              $tmp_name = $_FILES["file"]["tmp_name"];
              $namefile = $_FILES["file"]["name"];
              $ext = end(explode(".", $namefile));
              $image_name=time().".".$ext;
  
              $fileUpload = move_uploaded_file($tmp_name,"uploads/".$image_name);
              $Uploadthumbs = move_uploaded_file($tmp_name,"uploads/thumbs/".$image_name);            
          }
          $sqlAdd = mysql_query("insert into tbl_emp(name,image) VALUES('$name','$image_name')");
          header("Location:add.php?msg=success");
          exit;
      }
  }
      ob_end_flush();
  
      if(isset($_GET['msg']))
      {
          ?&gt;
          &lt;div style="color:red;padding-bottom:10px;" class="form-message" align="center"&gt;&lt;b&gt;Task completd successfully.&lt;/b&gt;&lt;/div&gt;
          &lt;?php
      }
  ?&gt;
  </code></pre>