在 Laravel 中显示存储的图像
Display stored image in Laravel
我是新手,我在 public/storage 中存储了图像,但我不知道如何显示它。
我在 UploadController 中有这个功能:
public function store(request $request)
{
if ($request->hasFile('file')) {
$request->file('file');
return $request->file->store('public');
}
return 'No file selected';
}
web.php中的这个:
Route::get('/', 'UploadController@index');
Route::post('store', 'UploadController@store');
welcome.blade.php中的这个:
{!! Form::open(['url' => '/store', 'method' => 'post', 'files' => true]) !!}
File name:
{!! Form::text('episode') !!}
{!! Form::file('file'); !!}
{!! Form::submit('Upload File') !!}
{!! Form::token() !!}
{!! Form::close() !!}
显示/store 中保存文件的名称
谁能告诉我如何显示图像?
'$request->file->store('public');' return 将使用唯一名称保存文件的路径,因此将 returned 路径保存在数据库中或如下所示的任何位置:
$path = $request->file->store('public');
现在 $path 变量包含您保存的文件的路径 (url)。
并使用此路径显示您存储的图像。
我是新手,我在 public/storage 中存储了图像,但我不知道如何显示它。
我在 UploadController 中有这个功能:
public function store(request $request)
{
if ($request->hasFile('file')) {
$request->file('file');
return $request->file->store('public');
}
return 'No file selected';
}
web.php中的这个:
Route::get('/', 'UploadController@index');
Route::post('store', 'UploadController@store');
welcome.blade.php中的这个:
{!! Form::open(['url' => '/store', 'method' => 'post', 'files' => true]) !!}
File name:
{!! Form::text('episode') !!}
{!! Form::file('file'); !!}
{!! Form::submit('Upload File') !!}
{!! Form::token() !!}
{!! Form::close() !!}
显示/store 中保存文件的名称
谁能告诉我如何显示图像?
'$request->file->store('public');' return 将使用唯一名称保存文件的路径,因此将 returned 路径保存在数据库中或如下所示的任何位置:
$path = $request->file->store('public');
现在 $path 变量包含您保存的文件的路径 (url)。 并使用此路径显示您存储的图像。