Return a file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Oak Hall

    Return a file

    I have files (pdf) that users can view. They are in a protected site.

    index.php's first function is to check the User Name and password. If they
    are ok, it answers the request.

    I want return a pfd file.

    So if a user goes to


    Index.php would check there user name and password then return the pdf file
    to the borwser. Can this be done??

    Thanks
    Oak


  • Oak Hall

    #2
    Re: Return a file

    I think I found the answer under header content type. Sorry. Thanks Oak

    "Oak Hall" <oak@scenicmls. com> wrote in message
    news:0a6Le.3960 $cg.30@news02.r oc.ny...[color=blue]
    >I have files (pdf) that users can view. They are in a protected site.
    >
    > index.php's first function is to check the User Name and password. If they
    > are ok, it answers the request.
    >
    > I want return a pfd file.
    >
    > So if a user goes to
    > http://www.mysite.com/index.php?comm...file=mydoc.pdf
    >
    > Index.php would check there user name and password then return the pdf
    > file to the borwser. Can this be done??
    >
    > Thanks
    > Oak
    >[/color]


    Comment

    • Oak Hall

      #3
      Re: Return a file

      I use the example, and get a return of garbage. If the content header not
      being understood??
      Thanks
      Oak

      Function view($qq)
      {
      $dir='c:\\redoa k\\working\\rec ords\\documents \\';
      //documentsin\
      // ll be outputting a PDF
      header('Content-type: application/pdf');

      // It will be called downloaded.pdf
      header('Content-Disposition: attachment; filename="downl oad"');

      // The PDF source is in original.pdf
      readfile($dir.$ qq['file']);
      }



      "Oak Hall" <oak@scenicmls. com> wrote in message
      news:Xc6Le.3961 $cg.2943@news02 .roc.ny...[color=blue]
      >I think I found the answer under header content type. Sorry. Thanks Oak
      >
      > "Oak Hall" <oak@scenicmls. com> wrote in message
      > news:0a6Le.3960 $cg.30@news02.r oc.ny...[color=green]
      >>I have files (pdf) that users can view. They are in a protected site.
      >>
      >> index.php's first function is to check the User Name and password. If
      >> they are ok, it answers the request.
      >>
      >> I want return a pfd file.
      >>
      >> So if a user goes to
      >> http://www.mysite.com/index.php?comm...file=mydoc.pdf
      >>
      >> Index.php would check there user name and password then return the pdf
      >> file to the borwser. Can this be done??
      >>
      >> Thanks
      >> Oak
      >>[/color]
      >
      >[/color]


      Comment

      • Chuck Anderson

        #4
        Re: Return a file

        Oak Hall wrote:
        [color=blue]
        >I use the example, and get a return of garbage. If the content header not
        >being understood??
        >Thanks
        >Oak
        >
        >Function view($qq)
        >{
        > $dir='c:\\redoa k\\working\\rec ords\\documents \\';
        > //documentsin\
        > // ll be outputting a PDF
        > header('Content-type: application/pdf');
        >
        > // It will be called downloaded.pdf
        > header('Content-Disposition: attachment; filename="downl oad"');
        >
        > // The PDF source is in original.pdf
        > readfile($dir.$ qq['file']);
        >}
        >
        >
        >
        >"Oak Hall" <oak@scenicmls. com> wrote in message
        >news:Xc6Le.396 1$cg.2943@news0 2.roc.ny...
        >
        >[color=green]
        >>I think I found the answer under header content type. Sorry. Thanks Oak
        >>
        >>"Oak Hall" <oak@scenicmls. com> wrote in message
        >>news:0a6Le.39 60$cg.30@news02 .roc.ny...
        >>
        >>[color=darkred]
        >>>I have files (pdf) that users can view. They are in a protected site.
        >>>
        >>>index.php' s first function is to check the User Name and password. If
        >>>they are ok, it answers the request.
        >>>
        >>>I want return a pfd file.
        >>>
        >>>So if a user goes to
        >>>http://www.mysite.com/index.php?comm...file=mydoc.pdf
        >>>
        >>>Index.php would check there user name and password then return the pdf
        >>>file to the borwser. Can this be done??
        >>>
        >>>Thanks
        >>>Oak
        >>>
        >>>
        >>>[/color]
        >>
        >>[/color]
        >
        >
        >
        >[/color]
        Here's what I use to accomplish the exact same thing (I'm pretty sure
        that I copied and pasted this from somewhere else):

        <?php
        header('Content-Description: File Transfer');
        header('Content-Type: application/pdf');
        header('Content-Length: ' . filesize($file) );
        header('Content-Disposition: attachment; filename=' . basename($file) );
        readfile($file) ;
        ?>

        --
        *************** **************
        Chuck Anderson • Boulder, CO

        Integrity is obvious.
        The lack of it is common.
        *************** **************

        Comment

        • Oak Hall

          #5
          Re: Return a file


          "Chuck Anderson" <websiteaddress @seemy.sig> wrote in message
          news:MZSdnZ2dnZ 1qw2ujnZ2dnd9nY d-dnZ2dRVn-0J2dnZ0@comcast .com...[color=blue]
          > Oak Hall wrote:
          >[color=green]
          >>I use the example, and get a return of garbage. If the content header not
          >>being understood??
          >>Thanks
          >>Oak
          >>
          >>Function view($qq)
          >>{
          >> $dir='c:\\redoa k\\working\\rec ords\\documents \\';
          >> //documentsin\
          >> // ll be outputting a PDF
          >> header('Content-type: application/pdf');
          >>
          >> // It will be called downloaded.pdf
          >> header('Content-Disposition: attachment; filename="downl oad"');
          >>
          >> // The PDF source is in original.pdf
          >> readfile($dir.$ qq['file']);
          >>}
          >>
          >>
          >>
          >>"Oak Hall" <oak@scenicmls. com> wrote in message
          >>news:Xc6Le.39 61$cg.2943@news 02.roc.ny...
          >>[color=darkred]
          >>>I think I found the answer under header content type. Sorry. Thanks Oak
          >>>
          >>>"Oak Hall" <oak@scenicmls. com> wrote in message
          >>>news:0a6Le.3 960$cg.30@news0 2.roc.ny...
          >>>
          >>>>I have files (pdf) that users can view. They are in a protected site.
          >>>>
          >>>>index.php 's first function is to check the User Name and password. If
          >>>>they are ok, it answers the request.
          >>>>
          >>>>I want return a pfd file.
          >>>>
          >>>>So if a user goes to
          >>>>http://www.mysite.com/index.php?comm...file=mydoc.pdf
          >>>>
          >>>>Index.php would check there user name and password then return the pdf
          >>>>file to the borwser. Can this be done??
          >>>>
          >>>>Thanks
          >>>>Oak
          >>>>
          >>>>
          >>>[/color]
          >>
          >>
          >>[/color]
          > Here's what I use to accomplish the exact same thing (I'm pretty sure that
          > I copied and pasted this from somewhere else):
          >
          > <?php
          > header('Content-Description: File Transfer');
          > header('Content-Type: application/pdf');
          > header('Content-Length: ' . filesize($file) );
          > header('Content-Disposition: attachment; filename=' . basename($file) );
          > readfile($file) ;
          > ?>
          >
          > --
          > *************** **************
          > Chuck Anderson • Boulder, CO
          > http://www.CycleTourist.com
          > Integrity is obvious.
          > The lack of it is common.
          > *************** **************[/color]

          This works THANKS! but it wants to download the pdf. How do I have it open
          in the borwser plugin??


          Comment

          • John Dunlop

            #6
            Re: Return a file

            Oak Hall wrote:
            [color=blue]
            > How do I have it open in the borwser plugin??[/color]

            I'd configure my own browser to associate application/pdf with
            whatever plugin I had in mind and then have it present the PDF
            to me 'inline'.

            [There's a hint there, if you find yourself heading down the
            rickety Content-Disposition road: 'inline' means something
            different to 'attachment'. But you never heard that from me,
            ok?]

            --
            Jock

            Comment

            Working...