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