第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Illuminate\Contracts\Filesystem\Factory 不可實例化

Illuminate\Contracts\Filesystem\Factory 不可實例化

PHP
縹緲止盈 2022-10-09 17:46:03
我嘗試使用 laravel 的獨立組件。在這種情況下,我嘗試使用Illuminate/http。它工作正常,除了上傳后保存的文件拋出異常。( ! ) Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Filesystem\Factory] is not instantiable. in /var/www/vendor/illuminate/container/Container.php on line 978( ! ) Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Filesystem\Factory] is not instantiable. in /var/www/vendor/illuminate/container/Container.php on line 978這是我的引導:use Illuminate\Http\Request;/** @var Request $request */$request = new Request(    $_GET,    $_POST,    [],    $_COOKIE,    $_FILES,    $_SERVER);這是我嘗試在本地存儲中存儲表單發(fā)布文件的部分:$request->image->store(APP_PUBLIC.'resources/assets/images/homepage/slider/test.jpg');我試圖將Illuminate\Filesystem\Filesystem()as Factory 注入到 Reqest 對象中,但它似乎不起作用。如何將文件系統(tǒng)工廠注入 HTTP 組件?
查看完整描述

2 回答

?
小怪獸愛吃肉

TA貢獻1852條經驗 獲得超1個贊

我通過正確添加必要的工廠、配置并注冊它們來修復它。


作曲家.json

{

    "require": {

        "illuminate/validation": "^6.16",

        "illuminate/filesystem": "^6.16",

        "illuminate/translation": "^6.16",

        "illuminate/http": "^6.16",

        "illuminate/config": "^6.16",

        "jenssegers/blade": "^1.2",

        "league/flysystem": "^1.0"

    },

}

引導文件管理器:

use Illuminate\Container\Container;

use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory;

use Illuminate\Http\Request;

use Illuminate\Filesystem\FilesystemManager;

use Illuminate\Config\Repository;


$instance = Container::getInstance();

$instance->bind('config', function () use ($instance) {

    return new Repository([

        'filesystems' => [

            'default' => 'local',

            'disks' => [

                'local' =>[

                    'driver' => 'local',

                    'root' => '/absolut/path/to/upload/dir/,

                ]

            ]

        ]

    ]);

});


$instance->bind(FilesystemFactory::class, function () use ($instance) {

    return new FilesystemManager($instance);

});


/** @var Request $request */

$request = new Request(

    $_GET,

    $_POST,

    [],

    $_COOKIE,

    $_FILES,

    $_SERVER

);


查看完整回答
反對 回復 2022-10-09
?
鳳凰求蠱

TA貢獻1825條經驗 獲得超4個贊

當使用獨立組件并希望使用文件系統(tǒng)Illuminate\Filesystem\Filesystem::move()時,可能是使用方法或其他方法將文件保存在磁盤上的最簡單方法。Illuminate\Http\Request請看下面的代碼:


<?php


use Illuminate\Http\Request;

use Illuminate\Filesystem\Filesystem;


// Bootstraps request object

$request = new Request(

    $_GET,

    $_POST,

    [],

    $_COOKIE,

    $_FILES,

    $_SERVER

);



// Illuminate\Http\UploadedFile is available on $request->image

$path = $request->image->path();

$extension = $request->image->extension();


// Don't use destination thus. It's for demonstration purpose only

// Make sure upload directory is writable         

$destination = 'uploads/' . mt_rand() . '.' . $extension;


// Here is the moment  

$file = new Filesystem();

$file->move($path, $destination);


查看完整回答
反對 回復 2022-10-09
  • 2 回答
  • 0 關注
  • 133 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號