php - Laravel 5.2 中如何检查文件是否存在

标签 php laravel-5 file-exists

我尝试了以下方法来检查文件是否存在:

@if(file_exists(public_path('/user_img/'.Auth::user()->id.'.jpg')))

即使文件存在,它也会返回false!

这有什么问题吗?

最佳答案

我已通过向用户 ID 添加大括号进行更正,并且它工作正常:

@if(file_exists(public_path().'user_img/{{ Auth::User()->id }}.jpg'))

关于php - Laravel 5.2 中如何检查文件是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39161145/

相关文章:

c - 在C语言中使用套接字创建服务器和客户端应用程序检查文件

php - 报告了不同的 php 版本

laravel - SSL 证书 : unable to get local issuer certificate mailgun

php - Laravel eloquent 仅返回 foreach 中第一个元素的结果?

不知道扩展名的PHP检查文件是否存在

PHP 和 SQL(尝试使用提交按钮更新我的数据库)

phpUnit -assertQuery 失败并显示

php - AngularJS 和 Laravel 4.2 从多个表中检索数据并连接它们

php - 使用 URL 到 API Rest 的日期过滤器 - Codeigniter

java - 在调用 openFileInput 之前检查文件是否存在