<?php
if (!extension_loaded('uploadprogress') && !@dl(PHP_SHLIB_SUFFIX == 'so' ? 'uploadprogress.so' : 'php_uploadprogress.dll'))
exit('uploadprogress extension 0.3.1 or later required!');
if (isset($_FILES['upload'])) {
// Remember to set upload_max_filesize AND post_max_size if you want to upload big files
set_time_limit(0);
echo '<pre>UPLOAD_IDENTIFIER: ' . $_REQUEST['UPLOAD_IDENTIFIER'].":\n" . print_r($_FILES, 1).'</pre>';
} elseif (isset($_GET['UPLOAD_IDENTIFIER'])) {
header('Content-Type: text/javascript');
printf("UploadProgress.__update('%s', %s);", $_GET['UPLOAD_IDENTIFIER'], json_encode(uploadprogress_get_info($_GET['UPLOAD_IDENTIFIER'])));
} else {
$uploadID = substr(md5(microtime(true)), 0, 10);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>PHP Upload Progress Meter with Prototype</title>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="uploadprogress.js"></script>
</head>
<body>
<div>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" target="upload">
<input type="hidden" name="MAX_FILE_SIZE" value="1073741824" />
<input type="hidden" name="UPLOAD_IDENTIFIER" value="<?php echo $uploadID; ?>" id="uploadIdentifier" />
<label for="uploadFile">File: </label><input id="uploadFile" name="upload" type="file" />
<input type="submit" value="Send File" />
</form>
<h4 id="uploadSpeed"></h4>
<iframe name="upload" src="about:blank" style="display: none; width: 0; height: 0;"></iframe>
</div>
</body>
</html>
<?php
}