Need help regarding download file script

Discussion in 'PHP' started by Pathan, Aug 6, 2011.

  1. #1
    Hello,

    i am using a script which is used to link a files if you have multiple servers, for example i have file located at abc.com/folder/1.mp3 now on my main server i use that script to link that 1.mp3 like this. mysite.com/download.php?id=001, now the issue is for mp3 files it start playing it instead of downloading, i am looking for solution so it may start downloading instead of playing it. The script coding is as follows.


    
    <?php
    
    $url[0] = "http://www.mysite.com";
    $url["01"] = "abc.com/folder/1.mp3";
    $url["02"] = "abc.com/folder/2.mp3";
    $url["03"] = "abc.com/folder/3.mp3";
    $url["04"] = "abc.com/folder/4.mp3";
    $url["05"] = "abc.com/folder/5.mp3";
    
    $id = $_GET['id'];
    
    if ($id <> '' && $url[$id] <> '')
    { header("Location: $url[$id]"); exit(); }
    else
    { header("Location: $url[0]"); exit(); }
    
    ?>
    
    
    PHP:
    I will appreciate your help.

    -Regards.
     
    Pathan, Aug 6, 2011 IP
  2. PHP Junior

    PHP Junior Peon

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    AddType application/octet-stream .mp3
    Code (markup):
    Add it to your .htaccess file and see if anything changes.
     
    Last edited: Aug 6, 2011
    PHP Junior, Aug 6, 2011 IP
  3. Pathan

    Pathan Well-Known Member

    Messages:
    2,196
    Likes Received:
    218
    Best Answers:
    0
    Trophy Points:
    165
    #3
    will it work if the files are not on my server? i mean those mp3 files i just have download.php file.
     
    Pathan, Aug 6, 2011 IP
  4. jaimegm

    jaimegm Member

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #4
    Hi there
    Other option is zip them first so they will have zip or rar extension and you won't have problems
     
    jaimegm, Aug 6, 2011 IP