如何从表单中获取文件以将其保存到Parse? 我尝试了几十种变体:
SELECT COUNT(rating_draft_result.id), u1.username, u2.username
FROM rating_draft_result
INNER JOIN users u1 ON rating_draft_result.user_id = u1.id
INNER JOIN users u2 ON rating_draft_result.result = u2.id
GROUP BY u1.username, u2.username
并在javascript中:
<form id="image_form" enctype="multipart/form-data" action="/upload/image" method="post">
<h3>Upload icon image: </h3>
<p><input id="image_file" name="image_file" type="file"></p>
<p><input id="event_submit" type="submit" value="Create" onclick="makeEventSnip();"></p>
</form>
我尝试按照他们在Parse的JS指南(https://parse.com/docs/js/guide)中所说的方式去做,但这也不起作用。它似乎没有从表单中抓取任何东西。我错过了什么?
答案 0 :(得分:1)
试试这个
var fileUploadControl = document.getElementById('image_file');
var file = fileUploadControl.files[0];
var name = "icon.png";
var iconImageFile = new Parse.File(name, file);
iconImageFile.save().then(function() {//you need to call after save the file
alert(iconImageFile._url);
}