title: "empty field" when updating, if no image is selected don't update the database?
body: <p>I have here the code for the updating the image, the updating is working fine when I select an image.  But when I try to do some updating without changing the image it is successfully updated.  When I look at my database the field is empty.  Whenever I try to update it and just leave the image as is it just saves an empty field.  When I try to to update and select an image to change the current image in the database it's working fine. I don't know what's wrong with it, there's no error.  Can somebody please help me with this?</p>
  
  <p><strong>user.class.php</strong></p>
  
  <pre><code>public function upload($id,$FILE_NAME,$FILE_SIZE,$FILE_TYPE)
  {
  $stmt = $this-&gt;db-&gt;prepare("UPDATE tish_images SET  FILE_NAME=:FILE_NAME,FILE_SIZE=:FILE_SIZE,FILE_TYPE=:FILE_TYPE WHERE id=:id");
  
  $errors= array();
  foreach($_FILES['files']['tmp_name'] as $key =&gt; $error )
  {
      if ($error != UPLOAD_ERR_OK)
      {
          $errors[] = $_FILES['files']['name'][$key] . ' was not uploaded.';
          return FALSE;
      }
      $file_name = $key.$_FILES['files']['name'][$key];
      $file_size = $_FILES['files']['size'][$key];
      $file_tmp  = $_FILES['files']['tmp_name'][$key];
      $file_type = $_FILES['files']['type'][$key];  
      if($file_size &gt; 2097152)
      {
          $errors[] = 'File size must be less than 2 MB';
          return FALSE;
      }
      try
      {
          $stmt-&gt;bindParam( ":id", $id);
          $stmt-&gt;bindParam( ":FILE_NAME", $file_name, PDO::PARAM_STR );
          $stmt-&gt;bindParam( ":FILE_SIZE", $file_size, PDO::PARAM_STR );
          $stmt-&gt;bindParam( ":FILE_TYPE", $file_type, PDO::PARAM_STR );
          $stmt-&gt;execute();
  
          $desired_dir="image_uploads";
  
          if(is_dir($desired_dir)==false)
          {
              mkdir($desired_dir, 0700);
          }
          if(is_file($desired_dir.'/'.$file_name)==false)
          {
              move_uploaded_file($file_tmp,$desired_dir.'/'.$file_name);
              return TRUE;
          }
          else
          {
              $new_file=$desired_dir.'/'.$file_name.time();
              move_uploaded_file($file_tmp,$new_file);  
              return TRUE;             
          }
      }
      catch(PDOException $e)
      {
        echo $e-&gt;getMessage();
        return FALSE;
      }   
  }
  }
  </code></pre>
  
  <p><strong>update.php</strong></p>
  
  <pre><code>&lt;?php
  
  include_once 'DB.php';
  
  $FILE_NAME = isset($_GET['FILE_NAME']) ? $_GET['FILE_NAME'] : '';
  $FILE_SIZE = isset($_GET['FILE_SIZE']) ? $_GET['FILE_SIZE'] : '';
  $FILE_TYPE = isset($_GET['FILE_TYPE']) ? $_GET['FILE_TYPE'] : '';
  
  if(isset($_FILES['files'])){
  $id = $_GET['id'];
  
    if($crud-&gt;upload($id,$FILE_NAME,$FILE_SIZE,$FILE_TYPE))
    {
      echo "&lt;script type='text/javascript'&gt;alert('Successfully Updated!'); &lt;/script&gt;";
    }
    else
    {
      echo "&lt;script type='text/javascript'&gt;alert('Updating Failed!');&lt;/script&gt;";
    }
  }
  
  &lt;body&gt;
    &lt;div class="container"&gt;
      &lt;p&gt;&lt;strong&gt;Survey Update&lt;/strong&gt;&lt;/p&gt;
      &lt;br /&gt;
  
    &lt;div id="Survey-Update"&gt;
      &lt;form method="POST" enctype="multipart/form-data" action=""&gt;
        &lt;table class='table table-bordered'&gt;
  
           &lt;?php echo $FILE_NAME; ?&gt;
           &lt;input type="file" name="files[]"  value="" multiple/&gt;
           &lt;br /&gt;
           &lt;br /&gt;
           &lt;input type="submit"/&gt;
  
  &lt;/table&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>