开发者

progress bar whats actually happening

I know this is a rookie question but whats actually happening with a progress bar what is it actually monitoring.

I figure the only way to understand it is to get this answer.

when i run a piece off php code how can i get a progress bar to monitor it while it runs untill completion off the code??

most progressbars i have seen are file upload and download. is it monitoring the amount off requests the browser sends when upload the file so its monitoring the bytes that are being transfer?

Can someone please give me a better und开发者_运维知识库erstanding off whats going on?

I just want a simple progress bar to monitor progress while my php code is running so say if i am running this simple code to backup a websites files and folders, how could i do this???

<?php if ( isset($_POST['backup']) ) {
      if(exec("cd {$_SERVER['DOCUMENT_ROOT']}/wp-content/plugins/s3bk/files;tar -cvpzf backup.tar ".get_option(    'isd-server')."")) { echo "done"; } 
}
<form id="backup" method='post' action=''>
<?php if (function_exists('wp_nonce_field')) { wp_nonce_field('s3bk-updatesettings'); } ?>
<input type='submit' class="button" name='backup' value='backup'>

sorry for the rookie question just really want to get my head around whats actually happening???

Thanks


You wouldn't be able to monitor something like that - you're exec()ing an external program from PHP, so PHP is suspended while that external process is active. As well, tar can't report in advance how much there is to do, it can only report on what it's done or is currently doing.

A progress bar works on the basis of (how much is done / how much there is todo) * 100. Without knowing in advance exactly how many files/bytes there are to back up with tar, you can't calculate a completion percentage.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜