Skip to content

Instantly share code, notes, and snippets.

@AliceLR

AliceLR/test.php

Created May 11, 2020
Embed
What would you like to do?
<?php
// NOTE: this code doesn't cause the segmentation fault very often, but if e.g. a large script
// is included here the crash happens more often.
if ($_GET['progress']) { var_dump(uploadprogress_get_info(strval($_GET['progress']))); die(); }
if ($_POST['UPLOAD_IDENTIFIER']) { die("it worked."); }
$uID = floor(microtime(true) * rand(0,65535));
?>
<html>
<body>
<script type="text/javascript">
function checkprogress() {
var h = new XMLHttpRequest();
function printprogress() {
if(h.readyState === XMLHttpRequest.DONE && h.status === 200) {
var date = new Date();
document.getElementById('out').innerHTML = h.responseText + "(" + date.getTime() + ")";
}
}
h.onreadystatechange = printprogress;
h.open('GET', 'test.php?progress=<?=$uID ?>', true);
h.send();
setTimeout(checkprogress, 200);
}
function getprogress() { setTimeout(checkprogress, 50); };
</script>
<form name="uploaderForm" action="#" enctype="multipart/form-data" method="post">
<input type="hidden" name="UPLOAD_IDENTIFIER" value="<?=$uID ?>"></input>
<input type="file" name="upload"></input>
<input type="submit" value="Upload" onclick="getprogress()"></input>
<div id="out"></div>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment