title: validate specified image on laravel 4
body: <p>how can i validate an image (not in $_FILES)</p>
  
  <p>this is not work</p>
  
  <pre><code>$input = array('image' =&gt; 'image.txt');
  $rules = array('image' =&gt; array('Image'));
  
  $validator = Validator::make($input, $rules);
  
  if($validator-&gt;fails()){
      return $validator-&gt;messages();
  } else {
              return true
      }
  </code></pre>
  
  <p>always return true</p>
  
  <p>There is Laravel validate image methods</p>
  
  <pre><code>/**
   * Validate the MIME type of a file is an image MIME type.
   *
   * @param  string  $attribute
   * @param  mixed   $value
   * @return bool
   */
  protected function validateImage($attribute, $value)
  {
      return $this-&gt;validateMimes($attribute, $value, array('jpeg', 'png', 'gif', 'bmp'));
  }
  
  /**
   * Validate the MIME type of a file upload attribute is in a set of MIME types.
   *
   * @param  string  $attribute
   * @param  array   $value
   * @param  array   $parameters
   * @return bool
   */
  protected function validateMimes($attribute, $value, $parameters)
  {
      if ( ! $value instanceof File or $value-&gt;getPath() == '')
      {
          return true;
      }
  
      // The Symfony File class should do a decent job of guessing the extension
      // based on the true MIME type so we'll just loop through the array of
      // extensions and compare it to the guessed extension of the files.
      foreach ($parameters as $extension)
      {
          if ($value-&gt;guessExtension() == $extension)
          {
              return true;
          }
      }
  
      return false;
  }
  </code></pre>