devina tijo
devina tijo

Reputation: 99

Public path lists all files in view

I am embedding a pdf file in my view, like this

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

It works fine if the variable $accessProfileDet->server_folder has value. $pdfUrl is my public path. If $accessProfileDet->server_folder is null, view lists all files in the public folder. Please suggest any easy solution for this. Since my images like website logo, banner etc are in public folder, I don't like to prefer a special route to solve this, Is there any alternative solution.

Upvotes: 3

Views: 43

Answers (1)

Nithin John
Nithin John

Reputation: 917

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

Upvotes: 1

Related Questions