find and open a pdf file

I have some 200 pdf files in a folder that I want to be able to open from a web browser I have the first part and it works letting me look for a pdf file in a folder but how to I tell it to open a pdf file.

[php]

open pdf

Frame Lookup

----- <?php $file_dir=$_Post['file_dir']; foreach(glob("./pdf/*.pdf") as $filename){ $filename = basename($filename); echo "".$filename.""; }

?>

">

[/php]

Do you want to open it in a second tab?
Do you want to open it in a separate window?
Do you want to download it and allow the browser to open in in Acrobat Reader?
Or, lastly, do you want to open it into a frame on your browser with other controls available?

All are possible, but, each much be handled differently. Quite often, this would be handled by creating a
list of just LINKS for each PDF file found. You can change your to be an unordered list instead
and make each list item (

  • ) an anchor that points to the actual file on your server. Then, you can
    use CSS to make a drop-down for the
      so it would appear just like a drop-down but be
      a list of links. Then, if pressed, they would open the file for you.

      Did that make sense? But, again, depends on how you want the opened file to be handled…

  • I would like to open it in a separate window.

    Well, first, PHP is SERVER-SIDE only. It runs on the server, not in the browser. Therefore, if you want to let
    the user open the PDF, you need to use a CLIENT-SIDE program code to execute it. You can do that with
    either Javascript, JQuery or HTML. NOT with PHP. It can be done with PHP by setting up a Javascript to run
    ONLOAD when the page is loaded into the browser, but, that gets tricky and does not always work as it really
    should.

    One easy way to handle this using your select clause code is to set up a JS or in this example a JQuery code
    function to pop out your extra page whenever the drop-down’s option is selected. Here is a sampler of how
    it would work. You should place the JQ code at the bottom of the page so it is after the select is totally
    populated. For some reason that seems to work better on some systems and certain browsers…
    Also, to allow the secondary page, you need to place the full URL for the PDF file. So, you have to
    alter your option to fit it in. Something like:
    [php] echo “”.$filename."";[/php]
    Then, the JQuery would be something like:
    [php]

    [/php]
    Remember, if the URL is not set up as a valid one, it will cause odd errors. If the PDF is to be displayed in
    a new window, it is just as if you typed that URL in. Should work for you! Good luck!

    Sponsor our Newsletter | Privacy Policy | Terms of Service