我可以在本地工作时上传我的图片,但是当我将我的网站移动到主机时,它不会上传图片,同时在数据库中获取它们的名称,
我的 filesystems.php
'default' => env('FILESYSTEM_DRIVER', 'local'),
disks' => [
'local' => [
'driver' => 'local',
'root' => public_path('images/'),
],
....
Run Code Online (Sandbox Code Playgroud)
我的上传代码示例:
if ($request->hasFile('imageOne')) {
$imageOne = $request->file('imageOne');
$filename = 'productone' . '-' . time() . '.' . $imageOne->getClientOriginalExtension();
$location = public_path('images/');
$request->file('imageOne')->move($location, $filename);
$product->imageOne = $filename;
}
Run Code Online (Sandbox Code Playgroud)
问题:
在主机中,我上传了
image name in database,但我的public/images文件夹中没有图像 。
任何的想法?
我发现有趣的文件夹在我的主人,我提出我的所有public文件夹中的文件服务器public_html,现在它在我的根呼吁创建另一个文件夹public以及里面有images文件夹,包括我上载到目前为止,所有的图像!
问题:
public/images在我的根目录中创建了新文件夹而不是使用我的public_html?我将此代码添加到我的public_html/index.php文件中,现在可以使用了。
// set the public path to this directory
$app->bind('path.public', function() {
return __DIR__;
});
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你。