我在我的Notemaking网站上使用EasyMDE文本编辑器,但是由于某些原因,uploadImage功能不起作用。
这就是我实例化EasyMDE的方式。
var easyMDE = new EasyMDE({
autofocus: true,
autorefresh: true,
spellChecker: false,
minHeight: '180px',
uploadImage:true,
});
答案 0 :(得分:0)
我正在寻找一种PHP方法,但这就是我得到的: https://github.com/Ionaru/easy-markdown-editor/pull/71
编辑:- 我用PHP弄清楚了 您还需要将“ imageUploadEndpoint”值设置为另一个文件,然后保存图像并打印json。 这就是我在PHP中所做的。
客户端:
var easyMDE = new EasyMDE({
uploadImage:true,
imageUploadEndpoint: 'upload.php'
});
服务器端(在upload.php中):
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
header('Content-Type: application/json');
//logic for saving the file
if(image_saving_successful)
{
$url = the_filepath_for_the_image_saved
echo '{"data": {"filePath": "'.$url.'"}}';
http_response_code(200);
exit;
}else{
echo '{"error": "your_error_message"}';
http_response_code(400);
exit;
}
}else{
header('location: index.php');
exit;
}
?>
对于不同的错误消息,会有不同的响应代码。检查Readme.md