2017-05-22 60 views
3

我嵌入我查看PDF文件,這樣公共路徑列出的所有文件鑑於

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

它工作正常,如果變量$accessProfileDet->server_folder具有價值。 $pdfUrl是我的公共道路。如果$accessProfileDet->server_folder爲空,則視圖列出公用文件夾中的所有文件。請爲此提出任何簡單的解決方案。由於我的圖片像網站徽標,橫幅等都在公共文件夾中,所以我不喜歡用特殊的路線來解決這個問題,是否有其他解決方案。

回答

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 
相關問題