【发布时间】:2014-05-05 00:05:47
【问题描述】:
我想在其中一列中添加包含图像的新对象,但它不保存我的图片,我的代码有什么错误吗?特别是保存图像的一部分!
我的 JavaScript 出现问题的地方:
它从不上传我的图片解析!
<script type="text/javascript">
Parse.initialize("key", "key");
var products = Parse.Object.extend("products");
var fileUploadControl = $("#profilePhotoFileUpload")[0];
if (fileUploadControl.files.length > 0) {
var file = fileUploadControl.files[0];
var name = "photo.png";
var parseFile = new Parse.File(name, file);
}
parseFile.save().then(function() {
//The file has been saved to Parse.
}, function(error) {
// The file either could not be read, or could not be saved to Parse.
});
</script>
这里我添加了html行来上传文件:
<input type="file" id="profilePhotoFileUpload">
【问题讨论】:
-
@A.Wolff 你有什么建议吗?
-
@Handsomeguy 你有什么建议吗?
-
这个问题是在根据代码发布答案后编辑的,Timothy 的答案仍然正确:首先保存您的 Parse File,然后(在该 Promise 的回调中)保存您的对象
标签: javascript image parse-platform