Jump to content

unknown time remaining in file download


shnizle

Recommended Posts

hey guys,

im having trouble with a simple script....

i use the following script to make a secure download for a file that im hosting:

 

<?
include "common.php";
commonConnectToDB();

$sql = "select * from contacts where now()-insertTime < 180";
$res = commonDoQuery($sql);
//if (mysql_num_rows($res) == 0)
//		return;

$asfname = "SetupWFMwizard.exe";
$filename = commonGetLayoutSwitchHtml("trialDownloadFileName", "ENG");
$realFileName = "loadedFiles/$filename";
$fsize = filesize($realFileName); 

/* waiting for PHP 5.3
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mtype = finfo_file($finfo, $filename);
finfo_close($finfo);
*/

$mtype = "application/exe";

// set headers
header("Pragma: no-cache");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Description: File Transfer");
header("Content-Length: $fsize");
header("Content-Type: $mtype");
header("Content-Disposition: attachment; filename=\"$asfname\"");
header("Content-Transfer-Encoding: binary");
//flush();
        
$file = @fopen($realFileName,"rb");
if ($file) {
  while(!feof($file)) {
    print(fread($file, 1024*);
    flush();
    if (connection_status()!=0) {
      @fclose($file);
      die();
    }
  }
  @fclose($file);
}
?>

 

 

for some reason when im downloading the file with that the script generates i don't have the file size / time left inside the download box , im getting  "unknown time remaining" , message due to file size unknown

does anyone see a problem with that script?

 

thank you

Link to comment
https://forums.phpfreaks.com/topic/192252-unknown-time-remaining-in-file-download/
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.