【发布时间】:2015-07-04 04:02:18
【问题描述】:
我想用 laravel 5 方法 ajax 覆盖 Summernote 中的图像上传,但我无法让它工作。
这是我的 php 方法
public function ajaxImage()
{
$file = Input::file('image');
$destinationPath = public_path();
$filename = $file->getClientOriginalName();
if(Input::file('image')->move($destinationPath, $filename)) {
echo $destinationPath.$filename;
}
}
这是我的 jquery 代码:
$(document).ready(function(){
$('#description').summernote({
height: 300,
onImageUpload: function(files, editor, welEditable) {
sendFile(files[0], editor, welEditable);
}
});
function sendFile(file, editor, welEditable) {
var data = new FormData();
data.append("file", file);
var url = '/articles/ajaximage';
$.ajax({
data: data,
type: "POST",
url: url,
cache: false,
contentType: false,
processData: false,
success: function(url) {
alert('Success');
editor.insertImage(welEditable, url);
}
});
}
});
我在以下控制台中收到错误:
POST http://marcus.dev/articles/ajaximage 500(内部服务器错误)
【问题讨论】:
-
找到您的解决方案 .... somrat.info/summarnote-image-upload-with-laravel
-
请不要在问题标题中添加已解决。
标签: php jquery laravel-5 image-upload summernote