【发布时间】:2019-01-15 02:41:05
【问题描述】:
我正在使用 mongoose/express/mongodb 创建博客。当我将带有 tinyMCE 的图像上传到我的博客并输入源时,该图像不会出现在我的博客上。 alt 在检查时出现,但来源没有。 tinyMCE 是否允许上传 url 图片或仅允许本地上传?如果确实允许,我该如何进行源上传?
创建路由的代码
<div class="form-group">
<!-- use TINYMCE for textarea -->
<label for="blogContent">Blog Content</label>
<textarea class="form-control" name="blog[body]" id="editor" cols="30" rows="10" type="hidden"></textarea>
</div>
<script>
tinymce.init({
selector: 'textarea',
height: 500,
menubar: false,
plugins: [
'advlist autolink lists link image charmap print preview anchor textcolor',
'searchreplace visualblocks code fullscreen',
'insertdatetime media table contextmenu paste code help wordcount'
],
toolbar: 'insert | undo redo | styleselect | bold italic backcolor | alignleft aligncenter alignright | bullist numlist outdent indent | image link | removeformat | help',
});
</script>
Here is me entering a photo locally
Here is the local photo populating in tinyMCE
Here is the front end of the blog with no image appearing
Here is the database entry in mlab missing the src attribute
【问题讨论】:
-
您是否设置了一个公共静态目录来提供图像/js/等服务?
-
不,我不知道那是一回事。
-
我给你写了一个答案,让我们看看如何实现这个。
标签: javascript node.js express mongoose tinymce