我的代码不保存 pdf,我需要显示它。可以的话也下载。
<td><a name="Manual" href="{{asset('storage/app').'/'.$machineData->getManual()}}">
Manual de {{$machineData->getMachineName()}}</a></td>
在控制器上我有这个
protected function downloadFile($src)
{
if(is_file($src))
{
$finfo=finfo_open(FILEINFO_MIME_TYPE);
$content_type=finfo_file($finfo,$src);
finfo_open($finfo);
$file_name=basename($src).PHP_EOL;
$size=filesize($src);
header("Content-Type: $content_type");
header("Content-Disposition: attachment; filename=$file_name");
header("Content-Transfer-Encoding: binary");
header("Content-Length: $size");
return true;
}
else
{
return false;
}
}
public function download(Request $request)
{
$note=$request->file('manual');
if(!$this->downloadFile(app_path(). $note))
{
return redirect("/machineIndex");
}
}
请帮忙,我只是想显示文件,谢谢!