Moved ctrl-v upload Javascript back to controller
This commit is contained in:
parent
aca9df2910
commit
afe6f7ed7f
2 changed files with 56 additions and 40 deletions
|
|
@ -54,42 +54,3 @@ upload_form_files_selected = function() {
|
|||
$('#file-form').submit(); // start upload
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function upload_paste(event){
|
||||
console.log("paste!");
|
||||
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
|
||||
|
||||
// /*Make Sure Only One File is Copied*/
|
||||
// if (items.length != 1) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
for (var i = 0 ; i < items.length ; i++) {
|
||||
var item = items[i];
|
||||
if (!item.type.startsWith('image/')){ continue }
|
||||
var file = item.getAsFile();
|
||||
console.log(file);
|
||||
upload_file_with_ajax(file);
|
||||
}
|
||||
}
|
||||
|
||||
function upload_file_with_ajax(file){
|
||||
var formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
$.ajax('#{{upload_receive_path}}' , {
|
||||
|
||||
type: 'POST',
|
||||
contentType: false,
|
||||
processData: false,
|
||||
data: formData,
|
||||
dataType: 'text',
|
||||
error: function(xhr, txt, err) {
|
||||
console.log("error: "+txt+" / "+err);
|
||||
},
|
||||
success: function(res) {
|
||||
console.log("AJAX file upload was ok");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue