简体   繁体   English

如何为流星项目添加将图像保存在 mongodb 集合中的“选择文件”按钮

[英]How to add a "select file" button that saves an image in a mongodb collection for a meteor project

I've made a form for a project I'm working on and in it there's the tipical text inputs: "First Name", "Last Name", "Address" etc, etc... but there's a problem I'm facing and it's due to my lack of knowledge in Meteor and maybe HTML and Javascript too... I tried searching in other places but I didn't seem to find exactly what I'm looking for.我为我正在处理的项目制作了一个表格,其中有典型的文本输入:“名字”、“姓氏”、“地址”等……但是我遇到了一个问题这是由于我对 Meteor 以及 HTML 和 Javascript 缺乏了解......我尝试在其他地方搜索,但似乎没有找到我正在寻找的确切内容。

Anyways what I'm looking for is a way to make that when a user clicks on a button it pops up a window that lets the user select an image from his or her computer and then it will be saved in a mongodb collection.无论如何,我正在寻找一种方法,当用户单击按钮时,它会弹出一个窗口,让用户从他或她的计算机中选择图像,然后将其保存在 mongodb 集合中。 It also has to show inside this form in a small image.它还必须以小图像显示在此表单中。

I tried looking, and so far I've found that the HTML has the "input" tag with the "file" attribute that makes the pop-up window I want, my problem is what do I do from there?我尝试查看,到目前为止,我发现 HTML 具有“输入”标签和“文件”属性,可以使弹出窗口成为我想要的,我的问题是我该怎么做? How do I link the event the user inputs and save the image into a mongodb collection?如何链接用户输入的事件并将图像保存到 mongodb 集合中?

I know this might sound really silly, I've seen many webpages and what not that have this kind of things... I'm really new at learning to code, and I really want to learn.我知道这听起来可能很傻,我看过很多网页,还有什么没有这种东西......我在学习编码方面真的很陌生,我真的很想学习。 So thank you for any help I can get.因此,感谢您为我提供的任何帮助。

There are 2 packkages on atmosphere you could use您可以使用 2 包大气

https://atmospherejs.com/vsivsi/file-collection https://atmospherejs.com/vsivsi/file-collection

https://atmospherejs.com/jalik/ufs https://atmospherejs.com/jalik/ufs

I have used the first of these successfully on several projects now, and recommend it.我现在已经在几个项目中成功地使用了其中的第一个,并推荐它。 File uploading is fiddly in any environment, but they come with examples and documentation, so it's quite possible to be successful.文件上传在任何环境中都很繁琐,但它们带有示例和文档,因此很有可能成功。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM