View pdf file with url in the database in the browser

Asked

Viewed 113 times

-2

Hello! I have an application that uploads the PDF file whose url is saved in the database and the file in a folder. By clicking the view button the pdf file opens in the browser.

<a href="view.php?id= NÃO SEI O QUE COLOCAR AQUI"><button type="button" class="button btn btn-link">View</button></a>

This is my view.php:

  <?php
      header('Content-type: application/pdf');
      echo $row['arquivo']; 
  ?>    

I don’t know what to do. Someone can help me?

2 answers

0

You’re making a bit of a fuss about the code.

Your link should open a URL like this:

http://seusite/view.php? pdf_id=24

On your view.php view page:

$pdf_id= $_REQUEST['pdf_id']; 
AQUI VAI A CONSULTA SQL para recuperar URL e arquivo.
  • What will <a href="view.php? pdf_id= HOW WILL LOOK HERE"><button type="button" class="button btn btn-link">View</button></a>.

0

Hello. In case, my view.php file would look like this? :

<?php
  $pdf_id = $_REQUEST['arquivo'];

  header('Content-type: application/pdf');
  echo $pdf_id;
?>

and my button as it would look?

<a href="view.php?id= COMO FICARIA AQUI "><button type="button" class="button btn btn-link">View</button></a>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.