Implémentation des options de téléversement
This commit is contained in:
parent
0c29e928bc
commit
144293faf2
2 changed files with 14 additions and 6 deletions
|
@ -27,13 +27,11 @@
|
|||
<input id="submitbtn" type="submit" value="Téléverser">
|
||||
</p>
|
||||
|
||||
<!-- <p id="expiry" class="jsonly" style="display: none;"> -->
|
||||
<p id="expiry" style="display: none;">
|
||||
<p id="expiry" class="jsonly" style="display: none;">
|
||||
<label for="expiration">Expiration du fichier :</label>
|
||||
<input type="number" id="expiration" min="1" max="30" /> jour(s)
|
||||
</p>
|
||||
<!-- <p id="maxdownload" class="jsonly" style="display: none;"> -->
|
||||
<p id="maxdownload" style="display: none;">
|
||||
<p id="maxdownload" class="jsonly" style="display: none;">
|
||||
<label for="maxdl">Nombre maximal de téléchargements :</label>
|
||||
<input type="number" id="maxdl" min="1" />
|
||||
</p>
|
||||
|
|
|
@ -6,7 +6,7 @@ document.getElementById('fileinput').setAttribute('multiple','');
|
|||
// get form
|
||||
const form = document.getElementById('dropzone');
|
||||
|
||||
function upload(file) {
|
||||
function upload(file,exp,maxdl) {
|
||||
// create the XHR
|
||||
const xhr = new XMLHttpRequest();
|
||||
|
||||
|
@ -28,6 +28,14 @@ function upload(file) {
|
|||
|
||||
// create and send the request
|
||||
xhr.open('PUT', '/' + file.name);
|
||||
// add headers
|
||||
if (exp != "") {
|
||||
xhr.setRequestHeader('Max-Days',exp);
|
||||
}
|
||||
if (maxdl != "") {
|
||||
xhr.setRequestHeader('Max-Downloads',maxdl);
|
||||
}
|
||||
// send file
|
||||
xhr.send(file);
|
||||
}
|
||||
|
||||
|
@ -38,9 +46,11 @@ form.addEventListener('submit', e => {
|
|||
|
||||
// get file list
|
||||
const files = document.getElementById('fileinput').files;
|
||||
const exp = document.getElementById('expiration').value;
|
||||
const maxdl = document.getElementById('maxdl').value;
|
||||
|
||||
// upload each file
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
upload(files[i]);
|
||||
upload(files[i],exp,maxdl);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue