From c739cf9923184e929b46242559b93fb121baf521 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Thu, 24 Feb 2022 15:04:48 -0600 Subject: Fix bug with windows not uploading the right mimetype Signed-off-by: Matt Strapp --- src/public/js/form.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/public') diff --git a/src/public/js/form.js b/src/public/js/form.js index 3fbeb50..724fb05 100644 --- a/src/public/js/form.js +++ b/src/public/js/form.js @@ -3,7 +3,7 @@ window.onload = function () { document.getElementById('nojs').hidden = true; document.getElementById('block').hidden = false; -}; +}; // File submit AJAX request // After successful upload, actuate the file by calling actuate() on the successfully uploaded file @@ -54,24 +54,24 @@ function actuate(file) { xhr.onreadystatechange = function () { if (xhr.readyState === 4) { let response = JSON.parse(xhr.responseText); - if (xhr.status === 200) { - console.log(response); + if (xhr.status === 200 || xhr.status === 500) { createDownload(response.file); - } else { - // Display upload error message to the user - document.getElementById('actuate-err').innerText = response.error; - // DEBUG: Print full error if unknown error occurs - if (xhr.status === 500) - console.error(response.error_msg); } - return; + // Display upload error message to the user + document.getElementById('actuate-err').innerText = response.error; + // DEBUG: Print full error if unknown error occurs + if (xhr.status === 500) + console.error(response.error_msg); } + return; }; } // Creates the download element function createDownload(response) { + if (!response) + return; const tempName = response.filename; const downloadName = response.name.split('.')[ 0 ]; const downloadLink = document.createElement('a'); -- cgit v1.2.3