Force PHP Download Security Script

Discussion in 'PHP' started by Kyunn, Jul 16, 2007.

  1. #1
    Hey, first of all please know I'm a complete newbie when it comes to php. Alright now onto my problem. I'm running my site, and wanted to force download mp3s. I got download.php working but I've read many different places that leaving the link as download.php?f=song.mp3 is a large security risk. Can anyone help me so it reads the files off as IDs instead? ie; download.php?id=223
     
    Kyunn, Jul 16, 2007 IP
  2. AsHinE

    AsHinE Well-Known Member

    Messages:
    240
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    138
    #2
    You can use database to store links between ID's and real file names. When you get an ID of a file you perfrom a query to fetch real file name and give necessary file to your visitor.
    Database structure will be like:
    id | int
    filepath | varchar
    And query like "SELECT filepath FROM mytable WHERE ID=3" for example.
    I guess you should learn about using databases in PHP.
     
    AsHinE, Jul 17, 2007 IP