Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

geekshubh's avatar

Laravel Validation Session Expired

This is my validation file

public function rules()
    {
        return [
            'classroom_id'  =>  'required',
            'subject_id'    =>  'required',
            'title'         =>  'required',
            'deadline'      =>  'required',
            'type'          =>  'required',
            'visibility'    =>  'required',
            'file_url'      =>  'mimes:jpeg,png,pdf|max:10000',
        ];
    }
    /**
    * Get the error messages for the defined validation rules.
    *
    * @return array
    */
    public function messages()
    {
      return
      [
        'classroom_id.required' => trans('validation.assignments.classroom_id'),
        'subject_id.required' => trans('validation.assignments.subject_id'),
        'title.required'  => trans('validation.assignments.title'),
        'deadline.required'=> trans('validation.assignments.deadline'),
        'type.required'=>trans('validation.assignments.type'),
        'visibility.required'=>trans('validation.assignments.visibility'),
        'file_url.max'=>trans('validation.assignments.file_size'),
        'file_url.mimes'=>trans('validation.assignments.file_type'),
      ];
    }

Whenever I try to upload a file which is not jpeg,png,pdf(mostly video or zip) and it is higher than 10000(Kb), it is showing session timeout on the page.

0 likes
5 replies
Cruorzy's avatar

Not sure, excellent troubleshooting will be to place a few dd(); after and before the validation, and see what gets accepted ans how far the excecution comes.

Maybe remove a few rules and see what rule gives you the obstacle.

Please or to participate in this conversation.