1. Go to this page and download the library: Download mpyw/laravel-file-errors library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mpyw / laravel-file-errors example snippets
use Mpyw\LaravelFileErrors\UploadError as Err;
return [
/*
|--------------------------------------------------------------------------
| Validation Language Lines
|--------------------------------------------------------------------------
|
| The following language lines contain the default error messages used by
| the validator class. Some of these rules have multiple versions such
| as the size rules. Feel free to tweak each of these messages here.
|
*/
/* ... */
// 'uploaded' => 'The :attribute failed to upload.',
'uploaded' => [
Err::TITLE_INI_SIZE => 'The :attribute exceeds the maximum filesize defined in the server.',
Err::TITLE_FORM_SIZE => 'The :attribute exceeds the maximum filesize defined in the form.',
Err::TITLE_PARTIAL => 'The :attribute was only partially uploaded.',
Err::TITLE_NO_FILE => 'The :attribute was not uploaded.',
Err::TITLE_CANT_WRITE => 'The :attribute could not be written on disk.',
Err::TITLE_NO_TMP_DIR => 'The :attribute could not be uploaded; missing temporary directory.',
Err::TITLE_EXTENSION => 'The :attribute upload was stopped by a PHP extension.',
Err::TITLE_UNKNOWN => 'The :attribute could not be uploaded due to an unknown error.',
],
/* ... */
];
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
class UserController extends Controller
{
public function update(Request $request)
{
$validator = Validator::make(
$request->all(),
[
'name' => '
namespace App\Providers;
use App\Services\Validation\Validator;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Validator as Validation;
class ValidationServiceProvider extends ServiceProvider
{
public function boot(): void
{
Validation::resolver(function (...$parameters) {
return new Validator(...$parameters);
});
}
}
namespace App\Services\Validation;
use Illuminate\Validation\Validator as BaseValidator;
use Mpyw\LaravelFileErrors\IncludesFileErrorDetails;
class Validator extends BaseValidator
{
use IncludesFileErrorDetails;
/* ... */
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.