目标:如果文件存在,请加载文件,否则加载default.png.
我试过了
@if(file_exists(public_path().'/images/photos/account/{{Auth::user()->account_id}}.png'))
<img src="/images/photos/account/{{Auth::user()->account_id}}.png" alt="">
@else
<img src="/images/photos/account/default.png" alt="">
@endif
Run Code Online (Sandbox Code Playgroud)
结果
它保持加载我的默认图像,而我100%确定1002.png存在.
如何正确检查该文件是否存在?