Django Rest Framework
0
Вклад в тег
$scope.choiceFile = () ->
partsName = $scope.file.name.split('.')
partsName.pop()
$scope.file.humanName = partsName.join('.')
$scope.file = _.extend $scope.file,
progress: 0
isUploading: false
isError: false
isComplete: false
$scope.uploadFile = (file) ->
file.isUploading = true
Upload.upload(
url: '/api/file/'
data:
file: file
param1: 1
param2: 2
).then( (resp) ->
file.isComplete = true
console.log "успешно загружен #{file.name}"
, (resp) ->
file.isError = true
console.log "Ошибка при загрузке #{file.name}"
, (evt) ->
file.progress = parseInt(100.0 * evt.loaded / evt.total)
)
<button ngf-select
class="btn btn-info hidden-lg hidden-md"
accept="*/*"
ngf-pattern="*/*"
ngf-change="choiceFile()"
ng-model="file">
Choice to upload
</button>