Link Redirect Like This

Discussion in 'PHP' started by ironmankho, Jan 20, 2013.

  1. #1
    hi folks !!!!!!!!!

    i need your help / suggestion how i can achieve this type of result in php / html

    when you open this link in browser a download .mp3 will save ..... i try many others methods but no success

    http://link1.songspk.pk/song1.php?songid=9629
    Code (markup):
     
    Solved! View solution.
    ironmankho, Jan 20, 2013 IP
  2. Sano000

    Sano000 Active Member

    Messages:
    52
    Likes Received:
    4
    Best Answers:
    5
    Trophy Points:
    53
  3. #3
    
    <?php
    // downloading a file
    $filename = $_GET['path'];
    // here you can have the full path to the file in the URL:
    //download.php?path=http://www.themp3.com/file.mp3
    // Or you can send an ID number and fetch the link from a database
     
    // fix for IE catching or PHP bug issue
    header("Pragma: public");
    header("Expires: 0"); // set expiration time
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");// browser must download file from server instead of cache
     
    // force download dialog
    header("Content-Type: application/force-download");
    header("Content-Type: application/octet-stream");
    header("Content-Type: application/download");
    header("Content-Disposition: attachment; filename=".basename($filename).";");
    /*
    The Content-transfer-encoding header should be binary, since the file will be read
    directly from the disk and the raw bytes passed to the downloading computer.
    The Content-length header is useful to set for downloads. The browser will be able to
    show a progress meter as a file downloads. The content-lenght can be determines by
    filesize function returns the size of a file.
    */
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".filesize($filename));
    @readfile($filename);
    exit(0);?>
    
    PHP:
     
    DanBrown, Jan 20, 2013 IP