AJAX single upload might be working, but permissions problems seem to cause failure.
This commit is contained in:
parent
3c5598407e
commit
eb1eb38c01
5
vendor/sabre/dav/lib/DAV/Browser/Plugin.php
vendored
5
vendor/sabre/dav/lib/DAV/Browser/Plugin.php
vendored
@ -179,7 +179,7 @@ class Plugin extends DAV\ServerPlugin {
|
|||||||
|
|
||||||
if ($this->server->emit('onBrowserPostAction', [$uri, $postVars['sabreAction'], $postVars])) {
|
if ($this->server->emit('onBrowserPostAction', [$uri, $postVars['sabreAction'], $postVars])) {
|
||||||
|
|
||||||
switch ($postVars['sabreAction']) {
|
switch ($postVars['sabreAction']) {
|
||||||
|
|
||||||
case 'mkcol' :
|
case 'mkcol' :
|
||||||
if (isset($postVars['name']) && trim($postVars['name'])) {
|
if (isset($postVars['name']) && trim($postVars['name'])) {
|
||||||
@ -221,7 +221,8 @@ class Plugin extends DAV\ServerPlugin {
|
|||||||
|
|
||||||
if ($_FILES) $file = current($_FILES);
|
if ($_FILES) $file = current($_FILES);
|
||||||
else break;
|
else break;
|
||||||
|
logger('$_FILES: ' . json_encode($_FILES));
|
||||||
|
logger('$file: ' . json_encode($file));
|
||||||
list(, $newName) = URLUtil::splitPath(trim($file['name']));
|
list(, $newName) = URLUtil::splitPath(trim($file['name']));
|
||||||
if (isset($postVars['name']) && trim($postVars['name']))
|
if (isset($postVars['name']) && trim($postVars['name']))
|
||||||
$newName = trim($postVars['name']);
|
$newName = trim($postVars['name']);
|
||||||
|
@ -9,24 +9,25 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="files-upload-tools" class="section-content-tools-wrapper">
|
<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}}
|
{{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">
|
<form method="post" action="" enctype="multipart/form-data">
|
||||||
<input type="hidden" name="sabreAction" value="put">
|
<input type="hidden" name="sabreAction" value="put">
|
||||||
<input class="form-group" id="files-upload" type="file" name="file">
|
<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>
|
<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>
|
</form>
|
||||||
<div class="clear"></div>
|
<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>
|
<fieldset>
|
||||||
|
|
||||||
<input type="hidden" id="MAX_FILE_SIZE" name="MAX_FILE_SIZE" value="300000" />
|
|
||||||
<input type="hidden" name="sabreAction" value="put">
|
<input type="hidden" name="sabreAction" value="put">
|
||||||
<div>
|
<div>
|
||||||
<label for="fileselect">Files to upload:</label>
|
<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 id="filedrag">or drop files here</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -37,6 +38,9 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
<div id="file-upload-list"></div>
|
<div id="file-upload-list"></div>
|
||||||
|
|
||||||
|
<div id="profile-rotator-wrapper">
|
||||||
|
<div id="profile-rotator"></div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -68,10 +72,24 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// call initialization file
|
//
|
||||||
if (window.File && window.FileList && window.FileReader) {
|
// try {
|
||||||
DragDropUploadInit();
|
// 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();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -99,6 +117,7 @@ function DragDropUploadInit() {
|
|||||||
submitbutton.hide();
|
submitbutton.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// file drag hover
|
// file drag hover
|
||||||
@ -125,8 +144,55 @@ function FileSelectHandler(e) {
|
|||||||
"</strong> size: <strong>" + f.size +
|
"</strong> size: <strong>" + f.size +
|
||||||
"</strong> bytes</p>"
|
"</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>
|
</script>
|
Reference in New Issue
Block a user