req = new XMLHttpRequest();
req.open("GET", "/progress", 1);
location ^~ /progress {
# proxy to upstream server
proxy_pass h_t_t_p://STORAGE-SERVER.com;
proxy_redirect default;
}
<iframe id="uploadframe" name="uploadframe" width="0" height="0" frameborder="0" border="0" src="about:blank">
<html>
<head>
</head>
<body>
{'filepath':'/user_upload/photo/2/232/23456/23456.jpg', 'filetype':'image', 'error':'0'}
</body>
</html>
</iframe>
<iframe id="uploadframe" name="uploadframe" width="0" height="0" frameborder="0" border="0" src="about:blank">
<html>
<head>
<script>
parent.location="h_t_t_p://mysite.com/uploadfile/index.php#{'filepath':'/user_upload/photo/2/232/23456/23456.jpg', 'filetype':'image', 'error':'0'}";
</script>
</head>
<body>
</body>
</html>
</iframe>
function fetch(uuid) {
req = new XMLHttpRequest();
req.open("GET", "/progress", 1);
req.setRequestHeader("X-Progress-ID", uuid);
req.onreadystatechange = function () {
if (req.readyState == 4) {
if (req.status == 200) {
/* poor-man JSON parser */
var upload = eval(req.responseText);
document.getElementById('tp').innerHTML = upload.state;
/* change the width if the inner progress-bar */
if (upload.state == 'uploading') {
bar = document.getElementById('progressbar');
w = 400 * upload.received / upload.size;
bar.style.width = w + 'px';
}else if (upload.state == 'done') {
// , ,
//
window.clearTimeout(interval);
bar = document.getElementById('progressbar');
bar.style.width = '401px';
//************** *********************************
var result = window.location.hash;
location.hash='progress'; //
result = result.slice(1); // '#'
//
//javascript ( )
//**********************************************************************
}
/* we are done, stop the interval */
if (upload.state == 'done' || upload.state == 'error') {
window.clearTimeout(interval);
}
}
}
}
req.send(null);
}
<h2> </h2><br/>
<form id="upload" enctype="multipart/form-data"
action="/upload.php" target="uploadframe" method="post"
onsubmit="openProgressBar(); return true;">
<input type="hidden" name="MAX_FILE_SIZE" value="300000000" />
<input name="Filedata" type="file" label="fileupload" />
<input type="submit" value="" />
</form>
<iframe id="uploadframe" name="uploadframe" width="0" height="0" frameborder="0" border="0" src="about:blank"></iframe>
<div id="progress" style="width: 400px; border: 1px solid black; height:10px; display: none;">
<div id="progressbar"
style="width: 0px; background-color: black; margin-left:-1px; border: 0px solid black; height:10px;">
</div>
</div>
<div id="tp">(progress)</div>
Source: https://habr.com/ru/post/79342/