【发布时间】:2018-05-15 19:05:07
【问题描述】:
我想打印 laravel Blade 文件的内容......文件包含用户的 html 表......当用户点击打印按钮时,它必须重定向到弹出的打印窗口......请帮助解决这个问题问题。
当前读取文件内容的代码......我不知道如何给出这个文件的路径......文件在resource/views/reports/table.blade.php
当前代码显示异常:
FileSystem.php 第 41 行中的 FileNotFoundException: 路径 printview_table 中不存在文件
控制器中的代码
public function printfile()
{
$filename = '/reports/printview_table.blade.php';
try
{
$contents = File::get($filename);
printfile($contents);
}
catch (Illuminate\Filesystem\FileNotFoundException $exception)
{
die("The file doesn't exist");
}
}
【问题讨论】:
-
你试过
File::get(base_path($filename));吗? -
为什么最终用户需要未编译刀片模板的代码?只是好奇
标签: php laravel-5 printing controller laravel-blade