[英]How to open a pdf file in new tab from controller PHP (laravel)
嗨,我是php編程的新手。 我現在正在使用laravel 5.2。
我已使用外部服務從html頁面創建pdf。 為此,我使用了pdfcrowd。 我將內容寫到本地系統中的pdf文件中。 它的位置是/var/www/html/testproject/test_pdf.pdf
。
工作正常。 現在我的要求是,我必須從控制器的新選項卡中打開該pdf文件。 我的控制器名稱是adminController。 在其中,我使用了一個函數來打開pdf。
請參見下面的代碼:
public function open_pdf() {
$file_location='/var/www/html/testproject/test_pdf.pdf';
----------?
}
請提出您的想法。
要了解的重要一點是,我們無法從php控制器中打開新標簽頁。 因此,在視圖頁面(testpage.blade.php)中,我在標記中使用了“ target =“ _ blank”代碼。 請參見下面的代碼: <a href="{{ url('/') }}/testproject/openpdf"> target="_blank"
嘗試在您的html標記中添加target="_blank"
,它將正常工作。 你可能有這樣的用途
<a href="{{ url('/') }}/testproject/openpdf">
請嘗試這個
<a href="{{ url('/') }}/testproject/openpdf" target="_blank">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.