Lassie Posted June 7, 2007 Share Posted June 7, 2007 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; } } Quote Link to comment https://forums.phpfreaks.com/topic/54597-solved-download-stopped-working/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.