Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6900961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:36:49+00:00 2026-05-27T07:36:49+00:00

The bellow code is a page with an IF statement calling the downloadpage. if

  • 0

The bellow code is a page with an IF statement calling the downloadpage.

if ($currentpdt<$updatedpdt)

  echo "updatedpdt is greater than currentpdt.";

else
  echo "updatedpdt is not greater than currentpdt";
  require("dlfile.php");

?>

The above page has other things on it, mostly just SQL connections to define variables. Notice if the IF statement is false the “dlfile.php” file is required. This file is as follows

<?php
// local file that should be send to the client
$local_file = 'dl.zip';
// filename that the user gets as default
$download_file = 'your-download-name.zip';

// set the download rate limit (=> 20,5 kb/s)
$download_rate = 20.5; 
if(file_exists($local_file) && is_file($local_file)) {
    // send headers
    header('Cache-control: private');
    header('Content-Type: application/octet-stream'); 
    header('Content-Length: '.filesize($local_file));

    header('Content-Disposition: attachment; filename="'.$download_file.'"');

    // flush content
    flush();    
    // open file stream
    $file = fopen($local_file, "r");    
    while(!feof($file)) {

        // send the current file part to the browser
        print fread($file, round($download_rate * 1024));    

        // flush the content to the browser
        flush();

        // sleep one second
        sleep(1);    
    }    

    // close file stream
    fclose($file);}
else {
    die('Error: The file '.$local_file.' does not exist!');
}

?>

When I run the dlfile.php file by itself it works just fine and the download prompt appears as it should. However when it is called by the first file this is what I get.

PKÇ`w?6J@T1popup.jsUT   %DÍN%DÍNUxz{]’ÏNÃ0ÆÏÉSX»¬›ª¶š8 PÅ×Á¤©ÛÚ8ÊŸmíÝIX7MœâXŸþì¤ZzE™`:Ä6vÜÀ/·œ}8?(ÝUæ   zÔh…G©‚£Ò-¡#Êã£Ò_î¦k9kæˆAxøÝÛÚƒ’XÀ{Lj1!P÷¯Ïœ<   éÇ䌱›CÎ8º…™H¡!ü¹DÔbÔŽÑJ´éJÕÍË©äÍ% ,:Îöˆ0xožÊ2awŸ® Û—Q†§ÂæÅÕµ|[rÎÊœ·J÷÷èÿDÎÂÂ4_PÃʰµ¦|$)Òp)n•EéÉ*té:¡‹ÊIKc*qõŒ.w>².a$ªoÑŒ˜dGÕú¡~¬ª|@Õ¾~¨ªÕsZM\E'6¿ø+È Î >këeиËu~çt+UÙRÑ‘.~‚u¹g›3?ó_PKÇ`w?ÌmO‹jpreview.phpUT %DÍN%DÍNUxz{­VmoÛ6þlýŠ«ÔöKq›]lÙh“¬/ȶ ñVÛ`Ðe3–I¤ì&AþûîHù-ΧmùDw÷<<ÝÝÃSXÎÊ Ž¥)7R%s1­4³BI0ÜZ!§&ÐüïJh>V2å­fÎyöêÖŒ}p„Ív/ˆæ=·°dZ°IÁ äZ-@Ȳ²àÈèh ƒÄ­£ñûËÑM´5ÿj·a»8ƒf³¥3& dÜÇxî%«Åmûg@È   2n3#ã>Ä[ÓE«ììê‰P:’Òɘå‡ìh|Âî,”½?ÀØû}=S<5ÄA˜ž‚Ðøæ,›ƒfvQ ȸò– ª²ùmûgØ´E3ž¨oc‘ ·®}‚]ûz&ÊÃV•OU¦ÛLÝ\Zn,äJÂ"ª2P*“jQZ°lÊM rh«KeZ4¬ÇÐì{ÿ ‰ôA£áRóéXó²`¨‡0nýY‡µ[Ñ÷Ãv«Æ´c#ÂcoÎ?¼ÁÅåÕåèò‚,D¢f™@ü¦%Êì¼µ–/(…ª¹å©…[¶du†·háYo'Jã?ÀdV³tŽ`(Ôª’f(‹ˆúѽ··a^Њ۸r¸ÞÛJK¤S²á à"Iš¬Ù†µ2P$D7©D‘AÉ4[`6°Vt61Ù‡úb€JÁ‘ªI¨k5³“󋄃Üëˆ(ð%¹ö|0©cOžF¢=!ç:Î¥ø\ 9ç^‡:Í>>«çÞ°RÝž%WâÖÁ¨U u:|mïôo"I¢ÏÓ’+që`×M0=·U _º>9óàD™ÜöÉ›/Ñ“]ØŽ‰ý°Æ$;AkvÞ³äeê¸/q J¯ZC÷$„ˆƒËTeÜÉ«–-Ñþ"Û‘T~ZÇÿ…Ósu¢‡ƒ 迸øõ|ôõú>Œ~¾‚ëßÞ]}<‡°Ç_^ŸÇñÅèÂ;N£“.Œ4“F+âøò—0€ú'œY[žÅñjµŠV¯#¥§ñèsL'Æ…R†G™ÍÂAÐw=,˜œ&!—ÎÀY6}Ú¼4uçÖµ} cƒ§3…×êŒÕ¡¼LB\º–KÛ±w%¡~JBË¿Yw|PCïÆ);o¾7Ò=/ðÂû¿¸…Q7o~ø±ÓÝ4†ôZVØ‚~Â6Áälך/_õcïÁBÈ9h^$¡±wø0ã܆0Ó<¯-ñ„‘v#œC¬"œ(­:ì&xNµªdÖIU¡ôÙwyž÷ð¦×S!qW¿*¿õƒYào*|½œ-Dqw¿s1ÉŽá-~°ÇðKnEŠƒ}ï®EÞqÉ]=Q?.w´_ú›º!®m^øN‚ëër8ØmK}ïῬ–Å.èéµHèß©ú¾;añ–Â7¿z¦Žâš:‹+{üǹŸÿ¦!~¿>ž»Ú}qeñãà?œæ(P^ä‘«k«ºª©b<Ç=»¿ýØÏTß]hÿPKÇ`w?6J@T1 ¤popup.jsUT%DÍNUxPKÇ`w?ÌmO‹j ¤preview.phpUT%DÍNUxPK‰X

I think the browser is trying to read the file as a web document but I am not sure. I have attempted to take out the tags in dlfile.php and I also switch the

header('Content-Length: '.filesize($local_file));

to

header('Content-Disposition: attachment; filename="'.$download_file.'"');

the code still executed fine by itself but generated the same weird output when called for by the original file.

I have tried to just put the code from dlfile.php into the original file and got the same output.

What’s wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:36:49+00:00Added an answer on May 27, 2026 at 7:36 am

    Actually it’s not. Without braces your code is interpreted as:

    if ($currentpdt<$updatedpdt) {
        echo "updatedpdt is greater than currentpdt.";
    } else {
      echo "updatedpdt is not greater than currentpdt";
    }
    
    require("dlfile.php"); //Is required no matter what
    

    Try using braces to increase readability and fix this problem:

    if ($currentpdt<$updatedpdt) {
        echo "updatedpdt is greater than currentpdt.";
    } else {
      echo "updatedpdt is not greater than currentpdt";
          require("dlfile.php"); //Now just included if the if is false
    }
    

    Also, if you echo something from you first file then the second file will not be able to set headers and the file’s raw contents will be outputted. So you’ll need to remove the echo’s from your first file so that only the zip’s contents gets outputted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

work on asp.net vs 05 C#.Master page header contain the bellow code <script type=text/javascript
The below code throws an error in Netbeans saying the include statement is not
The code below is working nearly flawlessly, however my value for page title on
I have uploaded a page with the code below to my joomla root directory.
I have a python psp page code is shown below. Currently it only prints
I was given the code below to disable a button on an ASP.Net page
The simple code block below can be served up in a static HTML page
I use the bellow code to load the main menu elements from some CMS,
The code bellow is the small starting point for a new way ( for
Given the code bellow, how do I style the radio buttons to be next

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.