我正在尝试创建一个简单的Web应用程序,该应用程序将要求用户填写一些问题,然后上传照片。我希望在按下“提交”按钮时将所有这些信息存储在Meteor集合中,但是FS集合包有一些困难。
这是相关的main.html:
<form class="photoForm">
Problem: <input type = "text" id = "problem" placeholder="page # problem #"><br><br>
Your group members <input type = "text" id="group" size="50"> <br><br>
Your questions and comments about this problem: <br><br>
<textarea name="comments" form="photo" rows="4" cols="70" placeholder="Enter text here..."></textarea>
<br>
Upload a snapshot of your work here: <input type = "file" id = "myFileInput">
<br /><br />
<input type="submit" value="submit" />
</form>
这是main.js:
Template.form.events({
'click input[type=submit]': function(event, template) {
console.log("form submit")
event.preventDefault();
FS.Utility.eachFile(event, function(file) {
Images.insert(file, function (err, fileObj){
//Inserted new doc with ID fileObj._id, and kicked off the data upload using HTTP
});
});
}
});
这是我的问题:
我只能在事件'change .myFileInput'上上传文件。我试图让它在“单击输入[类型=提交]”和“提交”上载,但它不上传文件。单击提交按钮时,是否有办法使它上载文件?
如何将各种文本字段中的数据添加到图像集中?我可以将这些添加项合并到Images.insert()命令中吗?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句