公共路径列出视图中的所有文件

时间:2017-05-22 06:43:28

标签: php laravel-5.3

我在我的视图中嵌入了一个pdf文件,就像这样

<embed src = "{{$pdfUrl.$accessProfileDet->server_folder}}" width="100%" height="600px" type="application/pdf">

如果变量$accessProfileDet->server_folder具有值,则它可以正常工作。 $pdfUrl是我的公共道路。如果$accessProfileDet->server_folder为null,则视图将列出公用文件夹中的所有文件。请为此建议任何简单的解决方案。由于我的网站标识,横幅等图片都在公共文件夹中,我不喜欢特殊的路线来解决这个问题,有没有其他解决办法。

1 个答案:

答案 0 :(得分:1)

Just place a blank html file named 'index.html' in your public folder. This will solve the issue. Also you can avoid embedding the code by an if condition like this,
@if($accessProfileDet->server_folder != '')
    <embed src="{{$pdfUrl.$accessProfileDet->server_folder}}" width="100%" height="600px" type="application/pdf">
@else
    <div class="no-pdf">No data available!</div>
@endif