javascript - parse.com multiple files upload failing -


i trying upload multiple files parse.com database using:

function uploadphotos() {     if ( files != null )     {         var count =0;         (var i=0;i<filecnt;i++)         {              file = files[i];             var photocomment = comments[i];             var parsefile = new parse.file("photo.jpg", file, "image/jpg");             parsefile.save().then(function() {                 // file has been saved parse.                 bk_photos[i] = new parse.object("bk_photos");                 bk_photos[i].set("bk_comment", photocomment);                 bk_photos[i].set("bk_photo", parsefile);                 bk_photos[i].save();                 count++;                 if(count == filecnt)                 {                     saveobject();                 }              }, function(error) {                 // file either not read, or not saved parse.                 console.log("error!");             }); 

this uploads same 1 file multiple times though files array contains different files.

this worked me

var imagefiles = document.getelementbyid("profilephotofileupload"); var fileslength = imagefiles.files.length;

  (var i=0;i< fileslength;i++){      var file = imagefiles.files[i];     var name = imagefiles.files[i].name; //this *not* need unique name     var parsefile = new parse.file(name, file);     parsefile.save().then(function() {        var pic = new parse.object.extend("pics");       pic.set("itempicture", parsefile);       pic.save();      }, function(error) {        //error handling      }); 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -