Skip to content

Instantly share code, notes, and snippets.

@AliceLR
Created May 11, 2020 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AliceLR/83b9386abb962486118578d6e99a5791 to your computer and use it in GitHub Desktop.
Save AliceLR/83b9386abb962486118578d6e99a5791 to your computer and use it in GitHub Desktop.
<?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