Laravel存放到错误的路径

时间:2018-01-10 17:47:13

标签: laravel

我已将我的项目添加到服务器进行生产。我将公共文件夹中的所有内容移到了public_html。我已经改变了索引。 php并在bootstrap之前删除了..该网站工作正常,但现在的问题是,当我上传任何图片laravel创建公共文件夹上传和上传图片,我无法查看图片,直到我将其移动到公共外面的上传文件夹,它支持上传从一开始就有。

任何人都知道如何更改上传路径???

3 个答案:

答案 0 :(得分:0)

在AppServiceProvider中添加此内容

if(env('APP_ENV') == "production"){
   $this->app->bind('path.public', function () {
       return base_path() . '/../public_html';
   });
}

答案 1 :(得分:0)

返回[

/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application. Just store away!
|
*/

'default' => env('FILESYSTEM_DRIVER', 'gad'),

/*
|--------------------------------------------------------------------------
| Default Cloud Filesystem Disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
*/

'cloud' => env('FILESYSTEM_CLOUD', 's3'),

/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
| Supported Drivers: "local", "ftp", "s3", "rackspace"
|
*/

'disks' => [

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

    'gad' => [
        'driver' => 'local',
        'root' => public_path().'/uploads',
        'url' => env('APP_URL').'/public/uploads/',
        'visibility' => 'public',
    ],

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

    's3' => [
        'driver' => 's3',
        'key' => env('AWS_KEY'),
        'secret' => env('AWS_SECRET'),
        'region' => env('AWS_REGION'),
        'bucket' => env('AWS_BUCKET'),
    ],

],

];

答案 2 :(得分:0)

您可以将图像存储在任何您喜欢的位置,  例如:

$destinationPath = 'uploads';
$request->file('photo')->move($destionation_path, file_name_you_give);