From 0e8e0b48b3fd6f4d6d0dd60039743371930af08d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 30 Nov 2017 19:05:24 -0800 Subject: more or less working chunked uploads on /cloud now. --- Zotlabs/Module/File_upload.php | 2 ++ view/js/mod_cloud.js | 50 ++++++++++++++++------------------------- view/tpl/cloud_actionspanel.tpl | 2 +- 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php index e2a6d45e5..90761fa9c 100644 --- a/Zotlabs/Module/File_upload.php +++ b/Zotlabs/Module/File_upload.php @@ -64,6 +64,8 @@ class File_upload extends \Zotlabs\Web\Controller { if($partial) { $x = save_chunk($channel,$matches[1],$matches[2],$matches[3]); + +logger('save_chunk: ' . print_r($x,true)); if($x['partial']) { header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0)); json_return_and_die($result); diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js index 0756c34e3..9f2a007f3 100644 --- a/view/js/mod_cloud.js +++ b/view/js/mod_cloud.js @@ -18,58 +18,46 @@ function UploadInit() { var submit = $("#upload-submit"); var count = 1; + $('#invisible-cloud-file-upload').fileupload({ url: 'file_upload', dataType: 'json', dropZone: filedrag, formData: $('#ajax-upload-files').serializeArray(), - maxChunkSize: 100000, // 4 * 1024 * 1024, + maxChunkSize: 4 * 1024 * 1024, add: function(e,data) { - $(data.files).each( function() { this.count = ++ count; prepareHtml(this) }); + $(data.files).each( function() { this.count = ++ count; prepareHtml(this); }); + data.submit(); }, -// submit: function(e,data) { -// e.preventDefault(); -// }, - -// done: function(e,data) { -// addeditortext(data.result.message); -// $('#jot-media').val($('#jot-media').val() + data.result.message); -// }, -// stop: function(e,data) { -// preview_post(); -// $('#profile-rotator').hide(); -// }, - }); - $('#upload-submit').click(function(event) { event.preventDefault(); $('#invisible-cloud-file-upload').trigger('click'); return false;}); + progress: function(e,data) { + + // there will only be one file, the one we are looking for + $(data.files).each( function() { + var idx = this.count; + // Dynamically update the percentage complete displayed in the file upload list + $('#upload-progress-' + idx).html(Math.round(data.loaded / data.total * 100) + '%'); + $('#upload-progress-bar-' + idx).css('background-size', Math.round(data.loaded / data.total * 100) + '%'); + }); + }, - // is XHR2 available? -// var xhr = new XMLHttpRequest(); -// if (xhr.upload) { - // file select -// fileselect.attr("multiple", 'multiple'); -// fileselect.on("change", UploadFileSelectHandler); + stop: function(e,data) { + window.location.href = window.location.href; + } - // file submit -// submit.on("click", fileselect, UploadFileSelectHandler); + }); - // file drop -// filedrag.on("dragover", DragDropUploadFileHover); -// filedrag.on("dragleave", DragDropUploadFileHover); -// filedrag.on("drop", DragDropUploadFileSelectHandler); -// } + $('#upload-submit').click(function(event) { event.preventDefault(); $('#invisible-cloud-file-upload').trigger('click'); return false;}); -// window.filesToUpload = 0; -// window.fileUploadsCompleted = 0; } // file drag hover diff --git a/view/tpl/cloud_actionspanel.tpl b/view/tpl/cloud_actionspanel.tpl index 8d39a8383..6b876d2ac 100644 --- a/view/tpl/cloud_actionspanel.tpl +++ b/view/tpl/cloud_actionspanel.tpl @@ -21,7 +21,7 @@
{{if $quota.limit || $quota.used}}{{/if}} -
+ -- cgit v1.2.3