$(document).ready(function() {
$('#summernote').summernote({
callbacks: {
onImageUpload: function(files, editor, $editable) {
sendFile(files[0],editor,$editable);
}
}
});
sendFile = function(file, editor, welEditable) {
data = new FormData();
data.append("file", file);
$.ajax({
url: '/summernote.php',
data: data,
cache: false,
contentType: false,
processData: false,
type: 'POST',
success: function(data){
console.log(data);
$('#description').summernote("editor.insertImage", data, 'filename');
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus+" "+errorThrown);
}
});
}
});
if( isset($_FILES['file']) && $_FILES['file']['error'] == 0 ) {
if( move_uploaded_file( $_FILES['file']['tmp_name'], $_FILES['file']['name'] ) )
echo 'good';
}
var a = [
{test: 'as', test1: 'asss', test2:[{hello: 'a', hell: 'b'}, {hello: 'a', hell: 'b'}]},
{test: 'as', test1: 'asss', test2:[{hello: 'a', hell: 'b'}, {hello: 'a', hell: 'b'}]},
{test: 'as', test1: 'asss', test2:[{hello: 'a', hell: 'b'}, {hello: 'a', hell: 'b'}]}
]
var b = []
a.forEach(function(item){
b.push({test: item.test, children: [ { hello: item.test2[0].hello } ] })
})
b