php - File Size Calculated but File Not Found -


i trying install "waiting time file download script using php , jquery" script found @ http://www.w3webtools.com/simple-page-download-file-using-php-and-jquery/

i have downloaded demo scripts , installed them in server @ /var/www/test/.

when try call demo files recognizes file size says file not found. http://4x4submods.tk/test/download.php?f=advance-security-login-system-using-php-mysql.zip

any ideas?

mod_rewrite enabled.

this works:

<?php header('content-type: text/html;charset=utf-8'); include 'include/config.php'; include 'include/function.php';  ?> <!-- edited point latest copy of jquery! --> <script src="http://code.jquery.com/jquery-2.0.0.js"></script><?php  $fname='hello.txt'; $download=1; if(!file_exists(upload_dir.'/'.$fname)) {     $download=0; }  $downloadlink='download/'.makehash($fname).'/'.$fname;   function file_size($url){      $size = filesize($url);      if($size >= 1073741824){          $filesize = round($size/1024/1024/1024,1) . 'gb';      }elseif($size >= 1048576){          $filesize = round($size/1024/1024,1) . 'mb';      }elseif($size >= 1024){          $filesize = round($size/1024,1) . 'kb';      }else{          $filesize = $size . ' bytes';      }      return $filesize;  }  ?> <div class="container">     <span class="filename" id="fileinfo-filename" title="<?=$fname?>"><?=$fname?></span>     <span class="fileinfo" id="fileinfo">file size: <span id="fileinfo-filesize"><?php      if($download!=0){         echo file_size(upload_dir.'/'.$fname);     }else{         echo 'n/a';     } ?></span> - ip: <span id="fileinfo-views"><?=$_server['remote_addr'];?></span></span> <div id="btnx" class="btn btn-blue">     <span class="text1" id="countdown-info">preparering download...</span>     <span class="timedown" id="countdown-time"></span>  </div> <div id="<?=$download?>" class="loading" style="display: none;"></div> <input id="download" type="text" style="display: none;" value="<?php echo $download ?>"> <a class="btn btn-green" id="btn-download" style="display: none;" href="<?=$downloadlink?>">     <span class="text2">download</span> </a>  </div> <script type="text/javascript">         http://w3webtools.com/wp-admin/post-new.php#     var countdown;      jquery(document).ready(function(){          countdown=function(start){             if(start==0)             {                 jquery('#countdown-time').html('');                 jquery('#countdown-info').html('preparering download...');                 bla = $('#download').val();                 if(bla==0){                     jquery('#countdown-info').html('error: press f5 try again. <br></br>404: file not found!');                 }else{                     jquery('#btnx').css('display','none');                     jquery('#btn-download').css('display','inline-block');                  }                 return true;             }             jquery('#countdown-time').html(start+'s');             start--;             settimeout('countdown('+start+')',1000);         }         countdown(5);     });  </script> 

function.php file:

<?php function makehash($filename) {     return md5( $filename . security_code ); } function verifyhash($filename,$hashcode) {     return $hashcode==makehash($filename); } 

ensure use same hash used in key when decoding!

the rest not required , made more complicated necessary!

including file date in hash, may make not work if file date changes reason, example, if need system restore. can put server name in hash if think want it!


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -