Jump to content

[SOLVED] Download stopped working


Lassie

Recommended Posts

I have a download script that was working and now is not.

Is there any addition I can make to the script to debug this.

I added the following line to make the download work and this is still there but no download when the file link is clicked.

The code that made it work was

ini_set("zlib.output_compression", "Off");

the relevant part of the script is

# If a download has already been selected,
#----------------------------------------- 
If ($_GET['file']){

# Get the filename to be downloaded
#----------------------------------
$file = $_GET['file'];
$file = stripslashes($file);
$file = htmlspecialchars($file);
$mainpath = "$path$file";

# Increment download count
#-------------------------
$filename = "./file_info/descriptions/$file.0";
$newfile = fopen($filename,"r");
$content = fread($newfile, filesize($filename));
fclose($newfile);
$fileinfo = explode ("|",$content);
$fileinfo[0] ++;

# Save the new file count
#------------------------
$content = implode("|", $fileinfo);
$newfile = fopen($filename,"w");
fwrite($newfile, $content);
fclose($newfile);

# Translate file name properly for Internet Explorer
#---------------------------------------------------
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")){
	$file = preg_replace('/\./', '%2e', $file, substr_count($file, '.') - 1);
}

# Make sure the file exists before sending headers
#-------------------------------------------------
if(!$fdl=@fopen($mainpath,'rb')){
   die("Cannot Open File!");
} else {

ini_set("zlib.output_compression", "Off");

# Send the headers then send the file
#------------------------------------
header("Cache-Control: ");# leave blank to avoid IE errors
header("Pragma: ");# leave blank to avoid IE errors
header("Content-type: application/force-download");
header("Content-Disposition: attachment; filename=\"".$file."\"");
header("Content-length:".(string)(filesize($mainpath)));

sleep(1);
fpassthru($fdl);

$counter++;
$to="@yahoo.co.uk";
	$subject="counter count";
	$msg="all files downloaded for folder $hash and counter equals $counter and files equals $_SESSION[num] and ";
	mail($to,$subject,$msg);

if ($counter==$_SESSION[num]) 
{
	$to="@yahoo.co.uk";
	$subject="download count";
	$msg="all files downloaded for folder $hash";

	mail($to,$subject,$msg);
	$counter=0;	
}
  
}

 

Link to comment
https://forums.phpfreaks.com/topic/54597-solved-download-stopped-working/
Share on other sites

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.