Hi,
i´m using Plug.Upload
to upload files.
How can i capture the % to make a progress bar?
thanks
Hi,
i´m using Plug.Upload
to upload files.
How can i capture the % to make a progress bar?
thanks
if you are asking about client side (js), then this would work fine, assuming you have an Upload controller that accepts post request on “/upload”
...
function sendFIle(file) {
var uri = "/upload";
var xhr = new XMLHttpRequest();
var fd = new FormData();
xhr.open("POST", uri, true);
xhr.upload.addEventListener("progress", function(e) {
if (e.lengthComputable) {
var percentage = Math.round((e.loaded * 100) / e.total);
}
}, false);
fd.append('myFile', file);
xhr.send(fd);
}
...
copied from MDN
Thank you. But i don´t see the connection between Plug.upload and this script. I think i need something like session.upload-progress from php in elixir.
AFAIK there is no such feature in current implementation of Plug.Session, and what if you want to store a session(all the session data) in encrypted cookie for example?
So, basically you’ll have to write it… Or using xhr request to send file(s) is another option