note 71565 deleted from features.file-upload by felipe

From: Date: Sun, 30 Dec 2007 17:56:07 +0000
Subject: note 71565 deleted from features.file-upload by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134332@lists.php.net to get a copy of this message
Note Submitter: jazfresh at hotmail.com ---- Sample code for the upload progress extension below. <?php // upload_progress.php // When the form is submitted, call this: // window.open('/upload_progress.php?id=' + upload_identifier, 'Upload_Meter','width=370,height=115,status=no', true); // Where 'upload_identifier' is the value of the hidden element UPLOAD_IDENTIFIER. $id = $_GET['id']; $body = false; // HTML body to display. $onload = false; // Javascript to run when the page loads. $refresh = false; // Number of seconds to wait before refreshing the page. false/0 means don't refresh. $info = false; // Table of information to display $url = htmlentities($_SERVER['PHP_SELF']).'?id='.$id.'&e=1'; // URL to redirect to. $ul_info = uploadprogress_get_info($id); if(!$ul_info) { if(isset($_GET['e'])) { $onload = 'window.close()'; $body = "Invalid upload meter ID!"; } else { $refresh = 2; // Wait 2 seconds, give the server time to create the progress file. $body = "Waiting for upload to begin."; } } else { if($ul_info['bytes_total'] > 1 && $ul_info['bytes_uploaded'] >= $ul_info['bytes_total'] && $ul_info['est_sec'] == 0) { $onload = 'window.close()'; $body = 'Upload complete.'; // They won't see this if the javascript runs, but just in case they've disabled it. } else { $body = "Uploading, please wait."; $refresh = 1; $percent_complete = $ul_info['bytes_uploaded'] * 100 / $ul_info['bytes_total']; $kb_per_sec = $ul_info['speed_last'] / 1000; $info = array( 'meter' => round($percent_complete, 2), 'width' => round($percent_complete), 'eta' => sprintf("%02d:%02d", $ul_info['est_sec'] / 60, $ul_info['est_sec'] % 60), 'speed' => round($kb_per_sec, ($ul_info['speed_last'] < 10000) ? 2 : 0), 'upl' => nice_value($ul_info['bytes_uploaded']), 'total' => nice_value($ul_info['bytes_total']), ); } } // The HTML meter display should follow here. ?>

« previous php.notes (#134332) next »