1

My form is this

<form name="form-basic" class="form-validation" ng-submit="uploadFile(updFrm.file)">
<input type="file" class="form-control" name="filee" id="files" ng-model="updFrm.file"/>
<input type="submit" value="click" class="btn btn-default">
</form>

I want to Pass Value of Input "file" into papaParse

Papa.parse(fileInput.files[0], {
    complete: function(results) {
        console.log(results);
    }
});

Now how to replace fileInput.files[0] with Value from " <input type="file" class="form-control" id="files" ng-model="updFrm.file"/>"

Please guide...

Alex Peters
  • 2,601
  • 1
  • 22
  • 29
Asad Ali Khan
  • 307
  • 4
  • 16
  • I made it work by using this ` $scope.uploadFile = function(){ x = document.getElementsByName("filee")[0].files[0]; // console.log($('#files')[0].files); Papa.parse(x, { complete: function(results) { console.log(results); } }); } ` – Asad Ali Khan Jan 11 '17 at 10:07

1 Answers1

0

Try to Change $scope.updFrm.file instead of fileInput.files[0]

//Or

in your function via

$scope.uploadFile = function(fileDetails)
{
  Papa.parse(fileDetails, {
    complete: function(results) {
        console.log(results);
    }
 });
}
Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234
  • Sorry it gives error TypeError: Cannot read property 'stream' of null at Object.t [as parse] (papaparse.min.js:6) at ChildScope.$scope.uploadFile – Asad Ali Khan Jan 11 '17 at 09:36
  • just try `fileDetails[0]` instead of `fileDetails` – Ramesh Rajendran Jan 11 '17 at 09:38
  • Sorry !! Error Cannot read property '0' of undefined at ChildScope.$scope.uploadFile – Asad Ali Khan Jan 11 '17 at 09:41
  • Actually i m successful in getting data from local file.... ` $('#files').parse({ config: config, before: function(file, inputElem) { console.log("Parsing file:", file); $scope.updAllow = true; }, complete: function() { console.log("Done with all files."); } });` But i m not getting to pass on the value INTO SCOPE of Angular – Asad Ali Khan Jan 11 '17 at 09:44