Jump to content

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

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.