I figured out something tonight that I thought I'd share.
I wanted to be able to give a user feedback as to the amount of bytes uploaded (reloading every 10 seconds) for large file uploads.
My solution first involves changing the tmp upload directory, so this might not be applicable to all, since you are not able to set this using .htaccess or ini_set (though you can ask your host to set this at the httpd.conf level - and maybe they already have). this way, the only thing this directory will contain is the current uploading file (plus the . and .. on unix)
The next step is to create a javascript popup (called as the first thing in the javascript onSubmit event handler for a form). The popup contains the following php page (additional notes below)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Upload Status</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="refresh" content="10">
</head>
<body>
Upload Status:<br>
<?php
$dir='/tmp/php';
if (is_dir($dir)) {
$dh = opendir($dir);
while(false!==($filename=readdir($dh))){
$fileArray[]=$filename;
}
if(count($fileArray)==3){ // 3 because of the . and .. files and the current uploading tmp file
sort($fileArray);
echo "Received: " . filesize("/tmp/php/".$fileArray[2]);
}elseif(count($fileArray)==2){ // not yet started uploading
echo "initializing upload ...";
}else{
echo "upload status: Unavailable<br>";
echo "reason: more than 1 upload in progress<br>";
echo "note: large files may take 30 minutes to upload";
}
}
?>
</body>
</html>
This checks to see if the file has started uploading yet. If not, it outputs "initiliazing upload". There's a meta refresh to refresh the popup every 10 seconds. Upon the first refresh, the file will have started uploading and the file size will be displayed (then every 10 seconds, it will refresh and show the new size). If there happen to be 2 file uploads in progress at one time, it simply echos that the upload status can't be determined.
I'm sure this can be enhanced in respect to what happens when the file has finished uploading, I just haven't done that at this point.