1

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
  • 9,700
  • 2
  • 27
  • 44
ruby.lee
  • 107
  • 8

1 Answers1

4

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