我想添加一个新的对象,其中包含一列图像,但它不会保存我的图片,我的代码中是否有任何错误?特别是保存图像的一部分!如何通过JavaScript将图像保存在Parse.com中?
我的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你有什么建议吗? – user3602314
@Handsomeguy你有什么建议吗? – user3602314
这个问题是根据代码发布回答后编辑的,Timothy的答案依然正确:先保存你的Parse文件,然后(在该Promise的回调中)保存你的对象 – Sandra