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)"
>
我Coffescript :
$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)">
,但我得到了相同的結果
'$ files' not'$ file' – przno 2014-10-03 14:02:08