2016-09-26 3 views
2

나는 파일을 서버에 업로드하기 위해 angularjs와 ng-file-upload를 사용하고 있습니다. 파일 이름을 가져 와서 서버에 같은 이름으로 저장할 수 있습니다.ng-file-upload에서 업로드 된 파일의 파일 이름을 얻는 방법

업로드 후 "파일 선택"버튼 근처에 파일 이름이 표시되지만 파일과 함께 파일 이름을 파일에 전달할 수 있도록 파일 이름을 범위 변수로 설정하려고합니다.

업로드 코드 :

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

    data:{file:$scope.file} 

}) 

있는 HTML이 :

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

답변

3
당신은 다음과 같이 액세스 할 수 있습니다

,

$scope.filename = $scope.file.name; 
2

으로 이것을 시도 ng-bind

<button type="button" ngf-select ng-model="formdata.file" name="file">Select</button> 

<div ng-bind="formdata.file.name"></div> 
+0

감사합니다,이 작품은 나를 위해 !!! –