skip to Main Content

I work with laravel and cms orchid. Why a validation error occurs when adding a file via the upload component.

  Layout::rows([
                 Select::make('user_id')
                     ->value($this->orders->user_id)
                     ->fromModel(User::class, 'familia'),
 
                 Upload::make('file')->maxFiles(1)->maxFileSize(50)
                     ->title('Файл для вывода')->acceptedFiles('.pdf,.doc,.docx,.txt'),
 
             ]);

Message of error: Validation error. File upload error.

enter image description here

Code php.ini

post_max_size                = 50M
upload_max_filesize          = 50M

Code file config/filesystem.php

   'default' => env('FILESYSTEM_DISK', 'local'),

    'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
            'throw' => false,
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
            //'throw' => false,
        ],

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
            'endpoint' => env('AWS_ENDPOINT'),
            'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
            'throw' => false,
        ],

    ],

    'links' => [
        public_path('storage') => storage_path('app/public'),
    ],

How to defeat a mistake?

2

Answers


  1. check your php.ini and config/filesystems.php are configured correctly or not.
    in you php.ini file upload_max_filesize & post_max_size should be 50M or greater

    upload_max_filesize = 50M
    post_max_size = 50M
    

    in your config/filesystems.php file follow this configuration

    'disks' => [
        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL') . '/storage',
            'visibility' => 'public',
        ],
    ],
    

    I hope this will solve your problem.

    Login or Signup to reply.
  2. The error lies in the fact that the address in the browser’s address bar differs from the one specified in the settings.

    The framework’s developers state that they do not support and do not plan to support installation in a subdirectory.

    If you are an experienced user, you might attempt to resolve this using configuration files (this was previously possible for Mix, but I haven’t tried it with Vite). However, such solutions do not guarantee proper functionality or support in the future.

    The best option would be to set up the environment according to the framework’s requirements.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search