简体   繁体   中英

How to open a pdf file in new tab from controller PHP (laravel)

Hi I am new to php programming. I am using laravel 5.2 now.

I have used an external service to create a pdf from my html page. For that I have used pdfcrowd. I wrote the content to a pdf file in my local system. Its location is /var/www/html/testproject/test_pdf.pdf .

It works fine. Now my requirement is that, I have to open that pdf file in a new tab from my controller. My controller name is adminController. Inside that I used a function to open the pdf.

Please see the code below:

public function open_pdf() {
  $file_location='/var/www/html/testproject/test_pdf.pdf';
  ----------?
}

Please suggest your ideas.

The important thing to understand is that, we can't open a new tab from php controller. So In the view page (testpage.blade.php) I used 'target="_blank" code in a tag. please see the code below: <a href="{{ url('/') }}/testproject/openpdf"> target="_blank"

Try to add target="_blank" in your html tags it will work fine. You may have use like this

<a href="{{ url('/') }}/testproject/openpdf">

please try with this

<a href="{{ url('/') }}/testproject/openpdf" target="_blank">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM