안녕하세요?
summernote에디터를 홈페이지에 연결하고 이미지업로드 부분을 해결하려는데 아무리해도 안됩니다. 특별히 에러도 없는 것 같은데... 많이 찾아보고 따라해도 되지 않네요... 경험이 있거나 웹프로그램 잘하시는 분이 계시면 소스라도 한 번 살펴봐주십시오... 감사합니다.
1. index.php
<!DOCTYPE html>
<html>
<head>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet">
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.12/summernote.css" rel="stylesheet">
<script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.12/summernote.js"></script>
</head>
<body>
<div class="container">
<form>
<textarea id="summernote"></textarea>
</form>
</div>
<script>
$(document).ready(function() {
$("#summernote").summernote({
placeholder:'place image here.',
height:300,
callbacks: {
onImageUpload:function(files,editor,welEditable){
for(var i = files.length - 1;i>=0;i--){
sendFile(files[i],this);
}
}
}
});
});
function sendFile(file, el){
var form_data = new FormData();
form_data.append('file', file);
$.ajax({
data:form_data,
type:"POST",
url:'editor-upload.php',
cache:false,
contentType:false,
processData:false,
success:function(url){
$(el).summernote('editor.insertImage',url);
}
});
}
</script>
</body>
</html>
2. editor-upload.php
<?php
if(empty($_FILES['file']))
{
exit();
}
$temp = explode(".", $_FILES["file"]["name"]);
$newfilename = round(microtime(true)).'.'.end($temp);
$destinationFilePath = './img-uploads/'.$newfilename;
if (!move_uploaded_file($_FILES['file']['temp_name'], $destinationFilePath)) {
echo "$errorImgFile";
}
else{
echo "$destinationFilePath";
}
?>
3. image-uploads 폴더 퍼미션은 777.
이상입니다...
더해서 증상은 이미를 올리면 아무런 반응이 없습니다. 폴더에도 이미지가 들어가지 않네요...