0

When I open this link

download.php?dir=files\Special-Download&file=maid-with-the-flaxen-hair.mp3

error occure like

Warning: Cannot modify header information - headers already sent by (

this is my php code

$files = new filemanager;
$dir = $files->get_absolute_path($_GET['dir']);
$filemg=explode('.',$_GET['file']);
$dwfile=$files->seo_friendly_url($filemg[0]).'.'.$filemg[1];
if (isset($_GET['file'])) 
{
    $file=$dir.DIRECTORY_SEPARATOR.$dwfile;
    $files->downloadFile($file);
}

i use this class

function downloadFile($dwf) {
    $file=str_replace('-',' ',$dwf);
    $ar_ext = explode('.',$file);
    $ext = strtolower(end($ar_ext));
    $extensions = array(
        'mp3' =>'audio/mp3'
    );
    $ctype = isset($extensions[$ext]) ? $extensions[$ext] : 'application/force-download';
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename="'.basename($file).'"');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    readfile($file);
}
Komal12
  • 3,340
  • 4
  • 16
  • 25

0 Answers0