【发布时间】:2022-01-24 04:27:44
【问题描述】:
我正在尝试打开存储在“storage/app/public/cca_license/pdf_upload”文件夹中的文件。当我尝试打开文件时,内容为空。
我试过的是
account.blade.php
<table id="table" class="table table-bordered text-center">
<thead>
<tr>
<th>PDF Name </th>
<th>Date</th>
<th>View</th><!-- comment -->
<th>Delete</th>
</tr>
</thead>
<tbody>
@if(count($pdf_data)> 0)
@foreach($pdf_data as $data)
<tr>
<td>{{$data->pdf_name}}</td>
<td>{{$data->pdf_date}}</td>
<td>
<a href="/openPdf/{{$data->pdf_name}}"><i class="fa fa-eye"></i></a>
<!-- <iframe id="ifrm" src="/cca_license/pdf_upload/txtfile-converted_1640170538.pdf" >
</iframe>-->
</td>
<td><a href="/deleteFile/{{$data->id}}"><i class="fa fa-remove"></i> </a></td>
</tr>
@endforeach
@else
<tr><td colspan="4">No Pdf Listings</td></tr>
@endif
</tbody>
</table>
web.php
Route::get('/openPdf/{name}', 'HomeController@openPdf');
HomeController.php
公共函数 openPdf($name) {
$contents=asset('cca_license/pdf_upload/'. $name);
}
当我尝试打开一个文件时,我得到一个没有文件内容的空白页面。
如何在浏览器中查看内容和文件。
【问题讨论】:
-
您没有返回响应。
-
@matticustard 如何返回响应?
标签: php laravel file model-view-controller file-storage