Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    53
    Thanks
    11
    Thanked 2 Times in 2 Posts

    File corrupt when downloaded from php

    Not exactly sure how to go about fixing this so I
    decided to ask here.

    If i go to /song.mp3 it downloads and plays just fine
    but if i use this php code.

    PHP Code:
    <?php
    $file 
    'song.mp3';
    _Download("".$file$file);
    function 
    _Download($f_location,$f_name){
        
    header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        
    header('Content-Description: File Transfer');
        
    header('Content-Type: audio/mpeg');
        
    header('Content-Length: ' filesize($f_location));
        
    header('Content-Disposition: attachment; filename=' basename($f_name));
        
    readfile($f_location);
     }
    ?>
    Gotta remove some of the code once I get it working correctly...

    The song downloads but is all skippy and corrupted
    sounding. Anyone know how to fix this?

    -Thanks
    JustBlaze

  • #2
    Regular Coder meth's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Thanks
    0
    Thanked 9 Times in 9 Posts
    Change the content-type header to "application/octet-stream" and test. If the stream is buggered, I'd say php errors are being written to the file.
    I do Web Design, Brisbane based.
    More time spent in PHP/MySQL Web Development.
    And Search Engine Optimisation takes up the rest of it.

  • #3
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I use for file load :
    Code:
    $data = file_get_contents($f_location);
    echo $data;
    Titti
    Textures


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •