0

在 ArticleController.php 中,数据以适当的扩展名上传到存储目录中,但在 homestread 数据库中,上传的照片数据为“/tmp/phpBqfse2”

public function store(Request $request)
{
Article::create($this->validateForm());
if ($request->hasFile('photo')) 
{
    $fileName = $request->photo->getClientOriginalName();   
    $request->photo->storeAs('uploads', $fileName, 'public');
}
    return redirect()->route('article.index')->with('success', 'Article data has been uploaded 
    successfully');
}

**In index.blade.php the data is not fetched by the following code **

<img src="{{ asset('uploads/'. $article->photo) }}" alt="Photo">

**Note**
storage is linked
php artisan storage:link
4

2 回答 2

0

因此,当您链接存储 ( php artisan storage:link) 时,您可以使用 访问存储{{ asset('storage/and/file.png') }}。举例说明您如何尝试访问“上传”文件夹并访问 jpeg。你会这样做:

<img src="{{ asset('storage/uploads/photo.jpeg') }}" alt="What you want">
于 2020-08-14T22:44:31.713 回答
0

如果文件系统是 Homestead 目录下 Homestead.yaml 中的#type: "nfs",文件将不会在 Windows 操作系统中显示。

于 2020-10-14T14:29:49.313 回答