laponac84 Posted December 2, 2013 Share Posted December 2, 2013 I try to upload fale(game.swf) from another webserver to my webserver, and that is not problem. Problem is create progress bar to track copying files process, or more precisely, the calculation and display the value in percentage, of file that i currently copied from other webserver to my webserver (alredy have full size of file variable) This is what i do for now.----------------------------------------------- after clik on install buton (div element) jq.js file $(".button").click(function () { var val = $(this).attr("id"); //id have url value for game i want to install http://www......game.swf $.post('proces.php',{val: val},function(data){ $(".final_data").html(data); }); }); proces.php file $link = $_POST['val']; // ... function remotefileSize($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_MAXREDIRS, 3); curl_exec($ch); $filesize = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); curl_close($ch); if ($filesize) return $filesize; } $b = remotefileSize($igrica_mochi); $mb = $b / 1048576; echo round($mb, 2). " Mb<br>"; //round(1.95583, 2); echo $b. " bytes<br>";// ...if (@copy($game_from_other_server, $game_in_my_server) ) { echo "- Finish!<br>"; }else{ echo "- Error.<br>"; $errors= error_get_last(); echo "- COPY ERROR: ".$errors['type']; echo "<br />\n".$errors['message']; }Formula for calculating procent isprogres = (current / full) * 100And question is value of 'current' Any ideas ? Quote Link to comment https://forums.phpfreaks.com/topic/284461-progress-bar-for-install-game/ Share on other sites More sharing options...
laponac84 Posted December 4, 2013 Author Share Posted December 4, 2013 This is what I managed to do it, but not good enough.I made a progress bar on the basis of completed processes. Problem occurs when the file (game) is large, and the progress bar is stationary for a long time until the whole game does not load on server. After that, script continue to load the rest of the process. For the user it is very important to have live information on what is currently happening. For these reasons, is really important to measure copy files from remote server to current server. (all processes other than copying files, are very short and quick, so it is not necessary to show them in progress bar becaose they ending in a split of second)As you can see, I do not have a html form , (Every example I found on the Internet is "Upload form") i have one xml file, which contains url of game. By clicking the install, I pick a game that I copied to current server from remote server. I get with the help jquery games file url, and sent (post) for processing in php fileExample Part of index.php file <div class="game"> <div style="float: none; margin: 5px ;" class="button" name="<?php echo $game['uuid']; ?>" id="url value">Install</div> <div id="<?php echo $game['uuid']; ?>"> </div> </div> jqerry file: $(".button").click(function () var value = $(this).attr("id"); $(this).hide(); $.post('process.php',{val: value},function(data){ $("#" + install).html(data); // collecting data }); $.post('process2.php',{val: value},function(data){ $("#" + install).html(data); // copy main file }); // rest call for process file... }); As you can see in my jquery file, I know the exact path of the file to be copied from the remote server ( ID of install div have that value) Process1.php, Process2.php , and rest... are quite the same file, which in the end have a progress bar in percentageHow to make progress bar, with this data ? Quote Link to comment https://forums.phpfreaks.com/topic/284461-progress-bar-for-install-game/#findComment-1461170 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.