mercredi 28 septembre 2016

How to strict video file to upload using ValidateRequest in laravel

I have a user registration form, where i am using file input box to upload image. Now the problem is , if i will select video file to upload it will pass ValidateRequest . In ValidateRequest, i already define the rule for image, below is the code:

class UserValidateRequest extends Request {

public function __construct() {

}

protected $messages = [
    'required.password' => 'We need to know your e-mail address!',
];
protected $rules = [      
    'first_name' => 'required|regex:"[a-zA-Z 0-9]"',
    'last_name' => 'regex:"[a-zA-Z 0-9]"',
    'image' => ' mimes:jpeg,jpg,png,gif |max:2048',           
];  

/**
 * Determine if the user is authorized to make this request.
 *
 * @return bool
 */
public function authorize() {
    return true;
}

public function messages() {
    return [
        'password.regex' => 'Password shall be 8-20 characters, must have a number and an alphabet',           ,
        'image.mimes' => 'Upload Gif || JPG || JPEG || PNG Images Only'
    ];
}

  public function attributes() {
      return[];
  }

}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2dn8ht3
via IFTTT

Aucun commentaire:

Enregistrer un commentaire