Jump to content

missing some byte with hedaer download function


marhoons

Recommended Posts

Hi every body,

 

when I have a media file grater than 5.44 MB I missing some byte in download with header function I don't know what exactly problem,

so look at my code and any commants please?

 


<?
include("connect/config.php");

$id= intval($_REQUEST["id"]);

$sql1= mysql_query("select * from $tsound where id='$id' ") or die("Error1");
$row1= mysql_fetch_array($sql1);

$sql2= mysql_query("select * from $tsound2 where id='$row1[mtype]' ") or die("Error2");
$row2= mysql_fetch_array($sql2);

$file= "media/$row2[mkdirs]/$row1[mpath]";

$len = filesize($file);
$filename = basename($file);
$stype = strtolower(substr(strrchr($filename,"."),1));

if ($stype=="mp3") { $ctype="audio/mpeg"; }
else if ($stype=="wmv") { $ctype="video/x-ms-wmv"; }
else { $ctype="audio/x-ms-wma";}

header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: $ctype");
$header="Content-Disposition: attachment; filename=".$row1[mtitle].";";
header($header);
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$len);
@readfile($file);
exit(print"<script>self.close(); <script>");

?>

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.