如何上传 public_html 中的图像而不是 laravel 中的项目文件?
how to upload images in public_html not in project file in laravel?
我将我的 Laravel 应用程序上传到 C 面板,我的 public 内容在 public_html 中,我将 public 上的 index.php 更改为:
require __DIR__.'/../thermotajhiz/vendor/autoload.php';
$app = require_once __DIR__.'/../thermotajhiz/bootstrap/app.php';
主根目录中的其他文件名为 thermotajhiz
一切正常,但是当我想上传图片而不是上传到 public_html 时,将在 thermotajhiz 中创建名称为 public 的文件public_html
之外的文件
我该如何解决这个问题?
我正在使用这个插件上传文件:
在config/filesystems.php
中这样设置
// Filesystem Disks
'disks' => [
'public' => [
'driver' => 'local',
'root' => '../public_html',
'url' => env('APP_URL'),
'visibility' => 'public',
],
],
如果不起作用尝试将 ../public_html
更改为 ../../public_html
或 /home/yourcpanelusername/public_html
并确保在 config/file-manager.php
中设置:
'leftDisk' => 'public',
我将此代码放入 index.php 而不是 AppServiceProvider 中的 register 方法,它起作用了:
$app->bind('path.public', function() {
return base_path('../public_html');
});
在此代码之后:
$app = require_once __DIR__.'/../thermotajhiz/bootstrap/app.php';
我将我的 Laravel 应用程序上传到 C 面板,我的 public 内容在 public_html 中,我将 public 上的 index.php 更改为:
require __DIR__.'/../thermotajhiz/vendor/autoload.php';
$app = require_once __DIR__.'/../thermotajhiz/bootstrap/app.php';
主根目录中的其他文件名为 thermotajhiz
一切正常,但是当我想上传图片而不是上传到 public_html 时,将在 thermotajhiz 中创建名称为 public 的文件public_html
之外的文件我该如何解决这个问题?
我正在使用这个插件上传文件:
在config/filesystems.php
中这样设置
// Filesystem Disks
'disks' => [
'public' => [
'driver' => 'local',
'root' => '../public_html',
'url' => env('APP_URL'),
'visibility' => 'public',
],
],
如果不起作用尝试将 ../public_html
更改为 ../../public_html
或 /home/yourcpanelusername/public_html
并确保在 config/file-manager.php
中设置:
'leftDisk' => 'public',
我将此代码放入 index.php 而不是 AppServiceProvider 中的 register 方法,它起作用了:
$app->bind('path.public', function() {
return base_path('../public_html');
});
在此代码之后:
$app = require_once __DIR__.'/../thermotajhiz/bootstrap/app.php';