You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using this module with the "vkholodkov/nginx-upload-module". And I cannot get the actual upload size. The module always return directly the file length in the remaining variable, see the following Nginx debug log:
server {
listen 127.0.0.1 default;
server_name _ ;
root /var/www/progress-bar;
index index.html;
client_max_body_size 768M;
error_page 405 = $uri;
}
server {
listen 80;
listen 127.0.0.1:80;
server_name progressbar.localhost;
client_max_body_size 768M;
error_log /var/log/nginx/error_progressbar.log debug;
location / {
# # proxy to upstream server
proxy_pass http://127.0.0.1;
proxy_redirect default;
location ~* upload$ {
# Pass altered request body to this location
upload_pass @uploading;
# Store files to this directory
# The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9 should exist
upload_store /tmp/uploads2;
# Allow uploaded files to be read only by user
upload_store_access user:rw;
# Set specified fields in request body
upload_set_form_field "${upload_field_name}_name" $upload_file_name;
upload_set_form_field "${upload_field_name}_content_type" $upload_content_type;
upload_set_form_field "${upload_field_name}_path" $upload_tmp_path;
# Inform backend about hash and size of a file
upload_aggregate_form_field "${upload_field_name}_md5" $upload_file_md5;
upload_aggregate_form_field "${upload_field_name}_size" $upload_file_size;
upload_pass_form_field "^submit$|^description$";
}
# track uploads in the 'proxied' zone
# remember connections for 30s after they finished
track_uploads proxied 30s;
}
location @uploading {
proxy_pass http://127.0.0.1;
}
location ^~ /progress {
# report uploads tracked in the 'proxied' zone
report_uploads proxied;
}
}
index.html
<html>
<head>
</head>
<body>
<form id="upload" enctype="multipart/form-data"
action="/index.html" method="post"
onsubmit="openProgressBar(); return true;">
<!--<input type="hidden" name="MAX_FILE_SIZE" value="30000000" />-->
<input name="userfile" type="file" label="fileupload" />
<input type="submit" value="Send File" />
</form>
<div>
<div id="progress" style="width: 400px; border: 1px solid black">
<div id="progressbar"
style="width: 1px; background-color: black; border: 1px solid white">
</div>
</div>
<div id="tp">(progress)</div>
</div>
<script type="text/javascript">
interval = null;
function openProgressBar() {
/* generate random progress-id */
uuid = "";
for (i = 0; i < 32; i++) {
uuid += Math.floor(Math.random() * 16).toString(16);
}
/* patch the form-action tag to include the progress-id */
document.getElementById("upload").action="/upload?X-Progress-ID=" + uuid;
/* call the progress-updater every 1000ms */
interval = window.setInterval(
function () {
fetch(uuid);
},
1000
);
}
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 == 'done' || upload.state == 'uploading') {
bar = document.getElementById('progressbar');
w = 400 * upload.received / upload.size;
bar.style.width = w + 'px';
}
/* we are done, stop the interval */
if (upload.state == 'done') {
window.clearTimeout(interval);
}
}
}
}
req.send(null);
}
</script>
</body>
</html>
The text was updated successfully, but these errors were encountered:
Hello,
I'm using this module with the "vkholodkov/nginx-upload-module". And I cannot get the actual upload size. The module always return directly the file length in the remaining variable, see the following Nginx debug log:
nginx.conf:
index.html
The text was updated successfully, but these errors were encountered: