Currently, I enter the exact file location like "c:\mydir\myfile.txt" in the input text box and hit the submit button. This gets captured as a string and posted to my webapi controller.
<div data-ng-controller="fileCtrl">
<form novalidate class="simple-form">
<input type="text" placeholder="Enter full file path here.." data-ng-model="filePath" />
<input type="submit" data-ng-click="LoadFilePath()" value="Submit" />
<div ui-grid="{ data: Rates }" class="grid"></div>
<p>Copy / Paste : </p>
<textarea style="height:200px; width:1000px; overflow:scroll;">{{InsertSQL}}</textarea>
</form>
</div>
app.controller('fileCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.LoadFilePath = function () {
//console.log('file path is ' + $scope.filePath);
$http
.post('http://localhost:1229/api/Rates' + '/processfile', '"' + $scope.filePath + '"')
.success(function (data) {
$scope.Rates = data.Rates;
$scope.InsertSQL = data.InsertSQL;
});
}
}]);
I want to
1) click the button
2) choose file name from the windows explorer
3) choose the above mentioned file.
4) take the PATH of the file and submit to the web api controller
How can I do that in angularjs?