summernote text editörü kullanıyorum araştırmalarıma göre bir işlem yaptım ama malesef resmi yükleyemiyorum ve db resim yolu gitmiyor. Sırası ile işlemlerim.
<div class="col-md-12">
<div class="block-flat">
<div class="content">
<textarea id="summernote" name="soru_aciklama"></textarea>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$('#summernote').summernote({
height: 200,
onImageUpload: function(files, editor, welEditable) {
sendFile(files[0], editor, welEditable);
}
});
function sendFile(file, editor, welEditable) {
data = new FormData();
data.append("file", file);
$.ajax({
data: data,
type: "POST",
url: "islem/soruislem.php",
cache: false,
contentType: false,
processData: false,
success: function(url) {
editor.insertImage(welEditable, url);
}
});
}
});
</script>islem/soruislem.php dosyam
if (isset($_POST['sorugonder'])) {
print_r($_REQUEST); die;
// ( [soru_kat_id] => 2 [soru_eti_id] => 5 [soru_baslik] => ssssssssssssss [soru_aciklama] =>
$tarih=date('Y-m-d H:i');
$baslik = trim(strip_tags($_POST['soru_baslik']));
$aciklama = trim($_POST['soru_aciklama']);
if ($_FILES['file']['name']) {
if (!$_FILES['file']['error']) {
$name = md5(rand(50, 100));
$ext = explode('.', $_FILES['file']['name']);
$filename = $name . '.' . $ext[1];
$destination = '/images/' . $filename; //change this directory
$location = $_FILES["file"]["tmp_name"];
move_uploaded_file($location, $destination);
echo 'http://localhost/evcil/images/' . $filename;//change this URL
}
else
{
echo $message = 'Ooops! Your upload triggered the following error: '.$_FILES['file']['error'];
}
}burdan sonrada db kayıt işlemine sokuyorum ama dosya yükleme işlemi yapamıyorum.