#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Force Download PDF is Corrupted


    Hi,

    I am using the following script to force download various pdf files from above the root, and it IS working BUT the files are corrupt! What am i missing?

    Any help would be greatly appreciated.

    HTML:
    Code:
    <p><a href="get-secure.php/course1_lesson_1_s.pdf">Download your PDF 1</a></p>
    <p><a href="get-secure.php/course1_lesson_2_s.pdf">Download your PDF 2</a></p>
    PHP:
    Code:
    <?php 
    $fileonly=$_GET['param']; 
    $file="../../secure_downloads/".$fileonly;  
    
    header("Content-type: application/force-download"); 
    header("Content-Length: $len"); 
    ?>
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,998
    Rep Power
    9397
    What you're missing is the "param" parameter.

    That, and your script allows anyone to download any file on your server.
  4. #3
  5. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,871
    Rep Power
    6351
    And $len comes from nowhere.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo