/* * The progress bar in PHP was contributed by * Mike Hodgson */ // Edit these to wherever your temporary files are stored. $info_file = "/tmp/$sessionid"."_flength"; $data_file = "/tmp/$sessionid"."_postdata"; function hms($sec) { $thetime = str_pad(intval(intval($sec) / 3600),2,"0",STR_PAD_LEFT).":". str_pad(intval(($sec / 60) % 60),2,"0",STR_PAD_LEFT).":". str_pad(intval($sec % 60),2,"0",STR_PAD_LEFT) ; return $thetime; } $started = TRUE; $total_size = $_GET['total_size']; $start_time = $_GET['start_time']; $time_now = time(); $sessionid = $_GET['sessionid']; if ($total_size == 0) { if ($fp = @fopen($info_file,"r")) { $fd = fread($fp,1000); fclose($fp); $total_size = $fd; } else { $started = FALSE; } } if ($started == TRUE) { if ($start_time == 0) { $start_time = $time_now; } $time_elapsed = $time_now - $start_time; if ($time_elapsed == 0) { $time_elapsed = 1; } $current_size = @filesize($data_file); $percent_done = sprintf("%.0f",($current_size / $total_size) * 100); $speed = ($current_size / $time_elapsed); if ($speed == 0) { $speed = 1024; } $time_remain_str = hms(($total_size-$current_size) / $speed); $time_elapsed_str = hms($time_elapsed); } header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Pragma: no-cache"); // HTTP/1.0 ?>
File Upload In Progress | ||
if ($started) { ?>
Time Elapsed: echo $time_elapsed_str; ?> Time Remaining: echo $time_remain_str; ?> |
} else { ?>
Waiting for file upload to begin...
} ?>