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 に答える