小编use*_*314的帖子

如何通过JavaScript在Parse.com中保存图像?

我想在其中一个列中添加包含Image的新Object,但它不能保存我的Pic,我的代码中是否有任何错误?特别是保存图片的一部分!!

问题出现的我的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>
Run Code Online (Sandbox Code Playgroud)

这里我添加了html行上传文件:

<input type="file" id="profilePhotoFileUpload">
Run Code Online (Sandbox Code Playgroud)

javascript image parse-platform

3
推荐指数
1
解决办法
7367
查看次数

标签 统计

image ×1

javascript ×1

parse-platform ×1