简体   繁体   English

从硬盘上传图像并将其插入短信

[英]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个步骤:

  1. Select image and upload it via HTML5 binary upload or iFrame uploader to your server. 选择图片,然后通过HTML5二进制上传或iFrame上传器将其上传到您的服务器。
  2. Once your server has received and handled the image, throw back the image path your browser. 服务器接收并处理了图像后,将图像路径返回浏览器。
  3. Display the image in your formular or wherever else - by now you should have the image url. 在您的公式编辑器中或其他地方显示图像-到目前为止,您应该具有图像URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用fabricjs从HTMlL5 canvas中的本地硬盘驱动器上传图像文件 - How to upload image file from local hard drive in HTMlL5 canvas using fabricjs 将图像保存到硬盘 - Save image to hard drive 使用javascript从网站将图像客户端下载到硬盘 - Downloading an image client side to the hard drive from a website using javascript javascript使用blob从本地硬盘加载图像 - javascript load image from local hard drive using blob 如何将图像从 url 上传到 Google Drive? - How to upload an image from an url to Google Drive? Google表格-从硬盘驱动器获取文件名并插入到表格中-(模拟Excel的Appication.GetOpenFilename) - Google Sheets - Get File Name from Hard Drive and Insert into Sheet - (Emulate Excel's Appication.GetOpenFilename) 通过我驱动器中的图像地址从文件或 postman 上传照片 - upload photo from file or postman by image address in my drive "使用谷歌脚本将从 webapp 获取的输入图像上传到谷歌驱动器" - Upload an input image taken from webapp into google drive with google script 图片从上传文件夹插入数据库 - image insert into db from upload folder Discord - 在嵌入消息中添加来自 Google Drive 的图像 - Discord - Add image from Google Drive in Embed Message
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM