10 months ago

File Validation

Posted 10 months ago by lawkunchi

I have form that requires a file. When a try to post this form I get this error "The id doc must be a file of type: jpeg, png, jpg, doc, docx, pdf."

Yet I uploaded the correct file. Don't tell me I should read the manual if you can't help, keep it to yourself!!

My controller

 public function postDeal(Request $request) 

        $this->validate($request, [
            'title' => 'string|required|max:100',
            'first_name' => 'string|required|max:100',
            'last_name' => 'string|required|max:100',
            'dob' => 'date|required',
            "id_doc" => 'required|mimes:jpeg,png,jpg,doc,docx,pdf|max:2048',
            'email' => 'email|required',

       $id_doc = $request->file('id_doc');

       $fileName = time().'.'.$id_doc->getClientOriginalExtension();

      $filePath = public_path('/uploads');
      $id_doc->move($filePath, $fileName);

        $deal = new Deal([
            'title' => $request->input('title'),
            'first_name' => $request->input('first_name'),
            'last_name' => $request->input('last_name'),
            'dob' => $request->input('dob'),
            'id_doc' => $filePath,
            'email' => $request->input('email'),

        return redirect()->route('dashboard');

Please sign in or create an account to participate in this conversation.