aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-07-23 07:59:28 -0400
committerAndrew Manning <tamanning@zoho.com>2016-07-23 07:59:28 -0400
commiteb1eb38c0174b542e388b32039589c0030ebd073 (patch)
treeb12935dc8fedb6ff5975bcaf4da391dc58cabcd2
parent3c5598407eb327c056d803b3afc4364fd6e107ab (diff)
downloadvolse-hubzilla-eb1eb38c0174b542e388b32039589c0030ebd073.tar.gz
volse-hubzilla-eb1eb38c0174b542e388b32039589c0030ebd073.tar.bz2
volse-hubzilla-eb1eb38c0174b542e388b32039589c0030ebd073.zip
AJAX single upload might be working, but permissions problems seem to cause failure.
-rw-r--r--vendor/sabre/dav/lib/DAV/Browser/Plugin.php7
-rw-r--r--view/tpl/cloud_actionspanel.tpl88
2 files changed, 81 insertions, 14 deletions
diff --git a/vendor/sabre/dav/lib/DAV/Browser/Plugin.php b/vendor/sabre/dav/lib/DAV/Browser/Plugin.php
index 49359a045..72b04065a 100644
--- a/vendor/sabre/dav/lib/DAV/Browser/Plugin.php
+++ b/vendor/sabre/dav/lib/DAV/Browser/Plugin.php
@@ -163,7 +163,7 @@ class Plugin extends DAV\ServerPlugin {
* @return bool
*/
function httpPOST(RequestInterface $request, ResponseInterface $response) {
-
+
$contentType = $request->getHeader('Content-Type');
list($contentType) = explode(';', $contentType);
if ($contentType !== 'application/x-www-form-urlencoded' &&
@@ -179,7 +179,7 @@ class Plugin extends DAV\ServerPlugin {
if ($this->server->emit('onBrowserPostAction', [$uri, $postVars['sabreAction'], $postVars])) {
- switch ($postVars['sabreAction']) {
+ switch ($postVars['sabreAction']) {
case 'mkcol' :
if (isset($postVars['name']) && trim($postVars['name'])) {
@@ -221,7 +221,8 @@ class Plugin extends DAV\ServerPlugin {
if ($_FILES) $file = current($_FILES);
else break;
-
+ logger('$_FILES: ' . json_encode($_FILES));
+ logger('$file: ' . json_encode($file));
list(, $newName) = URLUtil::splitPath(trim($file['name']));
if (isset($postVars['name']) && trim($postVars['name']))
$newName = trim($postVars['name']);
diff --git a/view/tpl/cloud_actionspanel.tpl b/view/tpl/cloud_actionspanel.tpl
index d4e187619..688b8f33d 100644
--- a/view/tpl/cloud_actionspanel.tpl
+++ b/view/tpl/cloud_actionspanel.tpl
@@ -9,24 +9,25 @@
</div>
<div id="files-upload-tools" class="section-content-tools-wrapper">
{{if $quota.limit || $quota.used}}<div class="{{if $quota.warning}}section-content-danger-wrapper{{else}}section-content-info-wrapper{{/if}}">{{if $quota.warning}}<strong>{{$quota.warning}} </strong>{{/if}}{{$quota.desc}}</div>{{/if}}
- <label for="files-upload">{{$upload_header}}</label>
+ <!--
+ <label for="files-upload">{{$upload_header}}</label>
<form method="post" action="" enctype="multipart/form-data">
<input type="hidden" name="sabreAction" value="put">
<input class="form-group" id="files-upload" type="file" name="file">
<button class="btn btn-primary btn-sm pull-right" type="submit" value="{{$upload_submit}}">{{$upload_submit}}</button>
- <!-- Name (optional): <input type="text" name="name"> we should rather provide a rename action in edit form-->
</form>
<div class="clear"></div>
-
- <form id="upload" action="" method="POST" enctype="multipart/form-data">
+ -->
+ <form id="ajax-upload-files" action="" method="POST" enctype="multipart/form-data">
+ <input type="hidden" name="sabreAction" value="put">
<fieldset>
- <input type="hidden" id="MAX_FILE_SIZE" name="MAX_FILE_SIZE" value="300000" />
<input type="hidden" name="sabreAction" value="put">
<div>
<label for="fileselect">Files to upload:</label>
- <input type="file" id="fileselect" name="fileselect[]" multiple="multiple" />
+<!-- <input type="file" id="fileselect" name="fileselect[]" multiple="multiple" />-->
+<!-- <input type="file" id="fileselect" name="fileselect[]" />-->
<div id="filedrag">or drop files here</div>
</div>
@@ -36,7 +37,10 @@
</fieldset>
<div id="file-upload-list"></div>
-
+
+ <div id="profile-rotator-wrapper">
+ <div id="profile-rotator"></div>
+ </div>
</form>
<div class="clear"></div>
</div>
@@ -68,10 +72,24 @@
<script>
$(document).ready(function() {
-// call initialization file
-if (window.File && window.FileList && window.FileReader) {
- DragDropUploadInit();
-}
+//
+// try {
+// var file_uploader = new window.AjaxUpload('submitbutton',
+// { action: 'cloud',
+// name: 'userfile',
+// title: 'Upload',
+// onSubmit: function(file,ext) { $('#profile-rotator').spin('tiny'); },
+// onComplete: function(file,response) {
+// $("#file-upload-list").append("Upload complete!");
+// $('#profile-rotator').spin(false);
+// }
+// });
+// } catch(e) {
+// }
+ // call initialization file
+ if (window.File && window.FileList && window.FileReader) {
+ DragDropUploadInit();
+ }
});
//
@@ -98,6 +116,7 @@ function DragDropUploadInit() {
// remove submit button
submitbutton.hide();
}
+
}
@@ -125,8 +144,55 @@ function FileSelectHandler(e) {
"</strong> size: <strong>" + f.size +
"</strong> bytes</p>"
);
+ DragDropUploadFile(f);
}
}
+// upload files
+function DragDropUploadFile(file) {
+
+ // Serialize the data in the form
+ //var serializedData = $('#ajax-upload-files').serialize();
+//
+// $.ajax({
+// type: "POST",
+// url: '',
+// data: serializedData,
+// success: function(result){
+// //window.console.log(result);
+// return false;
+// }
+// });
+//
+
+ var xhr = new XMLHttpRequest();
+ (xhr.upload || xhr).addEventListener('progress', function(e) {
+ var done = e.position || e.loaded
+ var total = e.totalSize || e.total;
+ console.log('xhr progress: ' + Math.round(done/total*100) + '%');
+ });
+ xhr.addEventListener('load', function(e) {
+ //console.log('xhr upload complete', e, this.responseText);
+ console.log('xhr upload complete', e);
+ });
+ xhr.open('post', 'cloud', true);
+
+ var data = new FormData(document.getElementById("ajax-upload-files"));
+ data.append('file', file);
+ xhr.send(data);
+//
+// var xhr = new XMLHttpRequest();
+// if (xhr.upload) {
+// // start upload
+// window.console.log("Uploading...");
+// xhr.open("POST", $("#ajax-upload-files").action, true);
+// xhr.setRequestHeader("X_FILENAME", file.name);
+// xhr.send(file);
+//
+// }
+
+}
+
+
</script> \ No newline at end of file