2

我正在尝试使用https://github.com/danialfarid/angular-file-upload但显然我无法访问该文件

我的 HTML

 <img 
    src = "{{ userPhotoUrl }}"
    alt = ""
    class = "img-circle img-responsive"
    accept = "image/*"
    data-multiple = "false"
    ng-file-select = "onFileSelect($file)"
>

我的咖啡脚本:

$scope.onFileSelect = ($file) ->
  console.log $file
  $scope.upload = $upload.upload
    url : '/api/upload/photo'
    file : $file
    method : 'POST'
  .progress (e) ->
    console.log 'percent' + parseInt 100.0 * e.loaded / e.total
  .success (data, status, headers, config) ->
    console.log data, status, headers, config

undefined刚从console.log($file)

有什么问题?我试图将相同的逻辑放入

<input type="file" ng-file-select="onFileSelect($file)">

但我得到相同的结果

4

1 回答 1

1

在 HTML 中更改$file$files

ng-file-select = "onFileSelect($files)"

这是文件上传暴露的东西,就像你可以使用$last$first一起使用ng-repeat

于 2014-10-03T14:06:33.890 回答