how to hide the url of a file for download

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • _andrea.l

    how to hide the url of a file for download

    I'd like to let user download a file but I'd like to hide the url of the
    file.
    I'd like to write something like that:

    <a href="download_ file.php?id=112 3">download file</a>

    download_file.p hp get the file and give it to user.
    BUT...
    .... how can I write download_file.p hp?
    thank you in advance for your help,
    Andrea.


  • Alvaro G Vicario

    #2
    Re: how to hide the url of a file for download

    *** _andrea.l wrote/escribió (Fri, 01 Jul 2005 07:59:43 GMT):[color=blue]
    > I'd like to let user download a file but I'd like to hide the url of the
    > file.[/color]

    Downloading a file from a hidden URL is like calling someone whose phone
    number is unknown...

    [color=blue]
    > ... how can I write download_file.p hp?[/color]

    Given that what you really want to know is how to write a download script,
    I've found this example in the manual page for header():


    <?php
    // We'll be outputting a PDF
    header('Content-type: application/pdf');

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

    // The PDF source is in original.pdf
    readfile('origi nal.pdf');
    ?>


    It shouldn't be difficult to write a generalization.

    --
    -- Álvaro G. Vicario - Burgos, Spain
    -- http://bits.demogracia.com - Mi sitio sobre programación web
    -- Don't e-mail me your questions, post them to the group
    --

    Comment

    • Tim Van Wassenhove

      #3
      Re: how to hide the url of a file for download

      On 2005-07-01, _andrea.l <andrea.lorizAN TISPAM@libero.i t> wrote:[color=blue]
      > I'd like to let user download a file but I'd like to hide the url of the
      > file.
      > I'd like to write something like that:
      >
      ><a href="download_ file.php?id=112 3">download file</a>
      >
      > download_file.p hp get the file and give it to user.
      > BUT...
      > ... how can I write download_file.p hp?
      > thank you in advance for your help,[/color]

      You could start a session on the previous page, and store $file in
      there...

      --
      Met vriendelijke groeten,
      Tim Van Wassenhove <http://timvw.madoka.be >

      Comment

      • John Dunlop

        #4
        Re: how to hide the url of a file for download

        _andrea.l wrote:
        [color=blue]
        > I'd like to let user download a file but I'd like to hide the url of the
        > file.[/color]

        Are you positive all your visitors are up for a game of hide
        and seek, _andrea.1?

        --
        Jock

        Comment

        • BKDotCom

          #5
          Re: how to hide the url of a file for download

          restrict the download to a "logged in" user?

          Comment

          • Dave Turner

            #6
            Re: how to hide the url of a file for download

            download.php ...

            <?
            set_time_limit( 600); // 600 secs (10 mins) maximum transfer

            $fname = $_GET["fname"];

            switch(trim(str tolower($fname) ))
            {
            case 'myfile1':
            $file = 'private/file1.zip'; break;
            case 'myfile2':
            $file = 'private/file2.zip'; break;
            default:
            Location("downl oadinvalid.php" ); exit;
            }

            header ("Pragma: no-cache"); // HTTP/1.0
            header('Content-Description: File Transfer\n');
            header("Content-type: application/octect-stream\n");
            header('Content-Length: ' . filesize($file) . "\n");
            header('Content-Transfer-Encoding: binary\n');
            header('Content-Disposition: attachment; filename=' . basename($file) .
            "\n\n");
            readfile($file) ;
            ?>


            usage:
            download.php?fn ame=myfile1



            Comment

            Working...