Commit d6d5f655 by Dányi Bence

one: client-side filesize validation added

parent ed96496e
...@@ -353,11 +353,21 @@ $(function() { ...@@ -353,11 +353,21 @@ $(function() {
/** /**
* Uploads the specified file(s) * Uploads the specified file(s)
*/ */
function readfiles(files) { function readfiles(file) {
var formData = tests.formdata ? new FormData() : null; //1 GB file limit
for(var i = 0; i < files.length; i++) { if(file.size > 1024*1024*1024) {
if(tests.formdata) formData.append('data', files[i]); $('#upload-zone').hide();
$('#upload-error').show();
$('#upload-error-size').show();
setTimeout(function(){
$('#upload-zone').show();
$('#upload-error').hide();
$('#upload-error-size').hide();
},3000);
return;
} }
var formData = tests.formdata ? new FormData() : null;
formData.append('data', file);
// now post a new XHR request // now post a new XHR request
if(tests.formdata) { if(tests.formdata) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
...@@ -414,7 +424,7 @@ $(function() { ...@@ -414,7 +424,7 @@ $(function() {
document.addEventListener('drop', function(e) { document.addEventListener('drop', function(e) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
readfiles(e.dataTransfer.files); readfiles(e.dataTransfer.files[0]);
return false; return false;
}); });
document.addEventListener('dragover', function(e) { document.addEventListener('dragover', function(e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment