Jump to content

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...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.