이미지 업로드 기능 추가

This commit is contained in:
2018-09-22 03:05:58 +09:00
parent 9a23470622
commit 32e3dcff7c
3 changed files with 158 additions and 1 deletions
+48 -1
View File
@@ -15,6 +15,12 @@ jQuery(function($){
function enableEditor(){
editMode = true;
$cancelEdit.show();
var inputText = $noticeInput.val();
if(!inputText || inputText == '<p></p>'){
inputText = '<p><br></p>';
}
console.log(inputText);
$editForm.removeClass('viewer').summernote({
minHeight:200,
maxHeight:null,
@@ -33,8 +39,49 @@ jQuery(function($){
],
fontNames: ['맑은 고딕', 'Nanum Gothic', 'Nanum Myeongjo', 'Nanum Pen Script', '굴림', '굴림체', '바탕', '바탕체', '궁서', '궁서체'],
fontSizes: ['8', '9', '10', '11', '12', '14', '16', '20', '24', '28', '32', '36', '40', '46', '52', '60'],
callbacks: {
onImageUpload: function(files) {
$editForm.summernote('saveRange');
if(files.length == 0){
alert('업로드된 파일이 없습니다.');
return false;
}
}).summernote('code', $noticeInput.val());
var formData = new FormData();
formData.append('img', files[0]);
$editForm.summernote("pasteHtml", '');
$.ajax({
type:'post',
url:'j_image_upload.php',
dataType:'json',
contentType: false,
processData:false,
data:formData
}).then(function(result){
if(!result.result){
alert(result.reason);
return;
}
console.log($editForm.summernote('code'));
if($editForm.summernote('isEmpty')){
console.log('haha?');
var $img = $('<img>');
$img.attr('src', result.path);
$editForm.summernote('code', $img);
return;
}
$editForm.summernote("insertImage", result.path, result.path);
},function(){
alert('알 수 없는 이유로 아이콘 업로드를 실패했습니다.');
});
}
}
}).summernote('code', inputText);
}
function disableEditor(){