我想添加一個新的對象,其中包含一列圖像,但它不會保存我的圖片,我的代碼中是否有任何錯誤?特別是保存圖像的一部分!如何通過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