Creating a pseudo filename for downloading? help!

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

    Creating a pseudo filename for downloading? help!

    Hi there all,

    I have an interesting problem....

    I work for a company that develops software for the building industry
    and would like to distribute one of our software products via the
    web.

    here is the problem

    The main file sits on my web server. We generate unique URLs for the
    buyer to download the software. We also generate unique filenames and
    store it in a database along with the unique URL This in essence is a
    pseudo filename

    When the user clicks on the URL that we send him I need the PHP
    script to initiate the file transfer giving the user the pseudo
    filename rather than the actual filename on the server

    I have everything working except for the ability to send the user the
    pseudo filename! at this moment in time we are sending them the same
    filename as the file sitting on our server.

    Is there anyway of doing this with PHP?



    Any help would much be appreciated


    Edit: In my code I have tried the following

    header('Content-Description: File
    Transfer');
    header('Content-Type: application/force-download'); //
    Tells the browser to expect a download
    header("Content-Transfer-Encoding: Binary"); //
    Tells the browser the format of the data
    header('Content-Length: ' .
    filesize($realf ilename)); // Tells the browser the size
    of the file
    header('Content-Disposition: attachment; filename=' .
    basename($uniqu efilename)); // Tells the browser the
    name of the file

    readfile($realf ilename);

    As you can see I am reading the original filename's properties however
    using the Content-Disposition header to tell the browser the filename
    to download!

    For some reason I.E always recieves a 0k file...???
    http://eye.cc php newsgroups
  • iavian

    #2
    Re: Creating a pseudo filename for downloading? help!

    <?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');
    ?>

    replace "downloaded.pdf " with u r pseudo file name ..

    Comment

    • iavian

      #3
      Re: Creating a pseudo filename for downloading? help!


      header("Content-Type: application/force-download");
      header("Content-Disposition: attachment;
      filename=\"file namehere.mp3\") ;

      filenamehere.mp 3 - have u r pseudo filename

      Comment

      Working...