[英]Upload image from hard drive & Insert it into text message
I wonder how to make such functionality by analogy as on stackoverflow's "ask question" page. 我不知道如何通过类似stackoverflow的“问问题”页面上的功能。 My purpose: I have a textarea to enter message and a button "Add image" above it.
我的目的:我有一个文本区域可输入消息,并在其上方有一个“添加图像”按钮。 On clicking the button I see the dialog with button "Choose file from hard drive".
单击按钮后,我看到带有按钮“从硬盘驱动器选择文件”的对话框。 Then I choose an image with appropriate extension and the image is inserted into the message.
然后,我选择具有适当扩展名的图像,并将该图像插入到消息中。 Then I post the message and the image is seen as an image among the text.
然后,我发布消息,并且该图像被视为文本中的图像。
How then images are stored in database? 图像如何存储在数据库中?
What is the best approach to make such thing? 制造这种东西的最佳方法是什么?
Thanks in advance. 提前致谢。
PS All my messages should be stored in MongoDB. PS我的所有消息都应存储在MongoDB中。 My views are JSP pages.
我的观点是JSP页面。
Create a folder, name it eg; 创建一个文件夹,命名为;
user_uplaods
and store image file name in DB. user_uplaods
并将图像文件名存储在DB中。 You already know the path where we are uploading files so no need to store path in DB. 您已经知道我们要上传文件的路径,因此无需在DB中存储路径。 When you need to display, fetch file name from DB and attach path to display that.
当需要显示时,请从数据库中获取文件名并附加路径以显示该文件名。
Basicly there are 3 steps: 基本上有3个步骤:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.