0
我试图在我的小应用程序中实现angular-file-upload
,但没有获得太大的成功。无法使用角度文件上传来上传文件
以我的index.html,我已正确添加参考
<script src="/Scripts/angular-file-upload.min.js"></script>
HTML
<div class="form-group">
<input type="file" name="FileUpload" class="btn btn-default btn-block" data-ng-file-select="onFileSelect($files)">
</div>
这是我的控制器代码。
//On select file
$scope.onFileSelect = function ($files) {
$scope.selectedFile = null;
if ($files.length > 0) {
$scope.selectedFile = $files[0];
$scope.attachment = {
lastModified: $scope.selectedFile.lastModified,
lastModifiedDate: $scope.selectedFile.lastModifiedDate,
name: $scope.selectedFile.name,
size: $scope.selectedFile.size,
type: $scope.selectedFile.type,
webkitRelativePath: $scope.selectedFile.webkitRelativePath
};
}
};
问题: 当我浏览和选择文件时,则触发该功能/被叫和$文件始终保持为空。
我在这里失踪了什么?
您是否将模块包含在角度应用配置中?例如。 'angular.module(“YourApp”,[“angularFileUpload”])' – tanenbring
是的,我加了。但仍然是这种情况。你能分享一个示例教程吗? – simbada