在laravel 5.3中,如果我从表单上传文件,它将存储在自己的存储目录中。然后我应该在public路径中创建一个符号链接到该存储路径。
但由于限制,我不能在系统上使用创建符号链接的方式。如何直接上传文件到public/uploads而不是storage/app/uploads?
我尝试在AppServiceProvider.php中设置路径,但它不起作用。
但由于限制,我不能在系统上使用创建符号链接的方式。如何直接上传文件到public/uploads而不是storage/app/uploads?
我尝试在AppServiceProvider.php中设置路径,但它不起作用。
public function register()
{
//not working:
$this->app->useStoragePath( $this->app->basePath() . "/upload");
//also not working:
// $this->app->bind('path.storage', function () {
// return $this->app->basePath() . '/upload';
// });
}
我所说的“not working”,是指它仍在上传到默认存储目录。我还清除了缓存。
这是上传部分(在控制器中使用):
$request->image->storeAs("uploads", "uploaded_image.jpg");
感谢任何提示。:)