javascript - Send image from filesystem to server in AngularJs -
i need send in background multiple-image , data server.
i'm using ionicframework (with angularjs) android app. i'm using angular-file-upload (directive) , following code factory:
if(angular.isarray(arrpictures) && arrpictures.length > 0) { var files = []; for(var i=0; i<arrpictures.length; i++) { files.push(arrpictures[i].photo); //it file://my_path/myimage.jpg } $upload.upload({ url: api_post_answer, method: 'post', data: { "idsurvey": idsurvey, "idoam": idoam, "idopm": idopm, "score": score, "date": date, "answerjson": answersjson, "address": address, "latitude": latitude, "longitude": longitude }, file: files, fileformdataname: "pictures" }).progress(function (evt) { //progress alert('progress: ' + parseint(100.0 * evt.loaded / evt.total) + '% file :'+ evt.config.file.name); }).success(function (data, status, headers, config) { // file uploaded alert('file ' + config.file.name + 'is uploaded successfully. response: ' + data); }).error(function (ex) { //error alert("error"); alert(ex); }); }
now have problem because server strings (path string) , not files question "how can convert path string file object send currectly server?"
my solution convert image base64 , store local db (using sqllite). after when want send image: query db, base64 string , send rest services.
all solution whitout using $upload directive $http service.
Comments
Post a Comment