How to get the progress status of the copy function in PHP? -


i need know how status of copy() function in php.

i using function download remote file, , want progress bar program.

you'll need write own copy function. first check file size through http head request, example solution:

http://php.net/manual/en/function.filesize.php#92462

then fetch file:

$remote = fopen('remote-file', 'r'); $local = fopen('local-file', 'w');  $read_bytes = 0; while(!feof($remote)) {   $buffer = fread($remote, 2048);   fwrite($local, $buffer);    $read_bytes += 2048;    //use $filesize calculated earlier progress percentage   $progress = min(100, 100 * $read_bytes / $filesize);   //you'll need way send $progress browser.   //maybe save file , let ajax call check it? } fclose($remote); fclose($local); 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -