0

Refer to Can an ASP.NET MVC controller return an Image? , the answer suggest to return image file from controller in C#.

My question is:

Can I do the same thing or similar in PHP? What I want is to hide PDF path from URL.

Thanks

abdusco
  • 7,899
  • 2
  • 23
  • 39
ruby.lee
  • 87
  • 7

1 Answers1

3

I think you are trying to hide the real local path of your pdf file using php. If this is the case, you can use something like this:

<?php

    $localfilename = 'my_local_path/my_file.pdf';

    header('Content-Type: application/pdf');
    header("Content-Disposition: attachment; filename='download.pdf'");

    readfile($localfilename);

?>

I hope this helps you. Greetings!

joelperez
  • 126
  • 2