title: Laravel File Upload Validation
body: <p>I'm new to Laravel. I have a form with a File upload function on it. How can I validate their file? I will only allowed Microsoft Word files. Here's my validation code.</p>
  
  <p>I just want check if they insert a ms word file and if not it will not be processed.</p>
  
  <pre><code>public function store()
  {
    // Validate
      $rules = array(
          'pda'                         =&gt; 'required|unique:forms',
          'controlnum'                  =&gt; 'required|unique:forms',
          'date'                        =&gt; 'required',
          'churchname'                  =&gt; 'required',
          'title'                       =&gt; 'required',
          'pastorname'                  =&gt; 'required',
          'contactnum'                  =&gt; 'required',
          'address'                     =&gt; 'required',
          'state'                       =&gt; 'required',
          'region'                      =&gt; 'required',
          'area'                        =&gt; 'required',
          'city'                        =&gt; 'required',
          'zipcode'                     =&gt; 'required|numeric|max:9999',
          'tgjteachertraining'          =&gt; 'required',
          'localcontact'                =&gt; 'required',
          'tgjdatestart'                =&gt; 'required',
          'tgjdateend'                  =&gt; 'required',
          'tgjcourse'                   =&gt; 'required|numeric',
          'childrengraduated'           =&gt; 'required|numeric|max:450',
          'childrenacceptjesus'         =&gt; 'required|numeric',
          'howmanycomitted'             =&gt; 'required|numeric',
          'recievedbibles'              =&gt; 'required|numeric',
          'descgradevent'               =&gt; 'required',
          'whatwillyoudo'               =&gt; 'required',
          'pastortest'                  =&gt; 'required',
          'teachertest'                 =&gt; 'required',
          'childrentest'                =&gt; 'required',
          'file'                        =&gt; 'required|max:10000',
      );
  
      $validator = Validator::make(Input::all(), $rules);
  
      // process the form
      if ($validator-&gt;fails()) {
          return Redirect::to('forms/create')-&gt;withErrors($validator);
      } else {
          // store
          $forms = new Forms;
          $forms-&gt;pda                         = Input::get('pda');
          $forms-&gt;controlnum              = Input::get('controlnum');
          $forms-&gt;date                = Input::get('date');
          $forms-&gt;churchname                  = ucwords(Input::get('churchname'));
          $forms-&gt;title                       = ucwords(Input::get('title'));
          $forms-&gt;pastorname                  = ucwords(Input::get('pastorname'));
          $forms-&gt;address                     = Input::get('address');
          $forms-&gt;contactnum                  = Input::get('contactnum');
          $forms-&gt;state                       = Input::get('state2');
          $forms-&gt;region                      = Input::get('region2');
          $forms-&gt;area                        = Input::get('area2');
          $forms-&gt;citytown                    = Input::get('city2');
          $forms-&gt;zipcode                     = Input::get('zipcode');
          $forms-&gt;tgjteachertraining          = Input::get('tgjteachertraining');
          $forms-&gt;localcontact            = ucwords(Input::get('localcontact'));
          $forms-&gt;tgjdatestart            = Input::get('tgjdatestart');
          $forms-&gt;tgjdateend              = Input::get('tgjdateend');
          $forms-&gt;tgjcourse           = Input::get('tgjcourse');
          $forms-&gt;childrengraduated           = Input::get('childrengraduated');
          $forms-&gt;childrenacceptjesus     = Input::get('childrenacceptjesus');
          $forms-&gt;howmanycomitted         = Input::get('howmanycomitted');
          $forms-&gt;recievedbibles          = Input::get('recievedbibles');
          $forms-&gt;descgradevent           = Input::get('descgradevent');
          $forms-&gt;whatwillyoudo           = Input::get('whatwillyoudo');
          $forms-&gt;pastortest          = Input::get('pastortest');
          $forms-&gt;teachertest             = Input::get('teachertest');
          $forms-&gt;childrentest            = Input::get('childrentest');
          $file                   = Input::file('file');
          $filename                   = $file-&gt;getClientOriginalName(); 
          $destinationPath                = 'uploads/'.Input::get('pda');
          $uploadSuccess              = Input::file('file')-&gt;move($destinationPath, $filename);
          $forms-&gt;docurl              = 'uploads/'.Input::get('pda').'/'.$filename;
          if( $uploadSuccess ) {
          $forms-&gt;save();
          //Session::flash('message', 'Successfully submitted form!');
          return Redirect::to('forms/create'); 
          Session::flash('message', 'Successfully submitted form!');
  
          } 
          else {
          return Response::json('error', 400);
          }
      }
  }
  </code></pre>