AngularJS Question

How to get the filename of the uploaded file in ng-file-upload

I am using angularjs and the ng-file-upload to upload a file to a server. I want to get the file name so that I can save it with the same name in the server.

After uploading I see the file name near the "choose file" button, but I want to set the file name to a scope variable so that I can pass the file name to server along with the file.

The upload code:

url: $scope.ipForHttp+"addVehicles?ClassificationID=" + $scope.C.ClassificationID + "&ClassName=" +
$scope.C.ClassName + "&ClassRate=" + $scope.C.ClassRate + "&ClassImage="+$scope.file+"&ClientID=1",



The html:

<input type="file" ngf-select ng-model="file" name="file"
ngf-pattern="'image/*'"accept="image/*" ngf-max-size="20MB" />

Answer Source

You can access like this,

   $scope.filename = $;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download