I am trying to upload a file. I have a working example which does it like this:
<div class="btn btn-default btn-fileinput">
<span class="glyphicon glyphicon-upload"></span> <input
type="file" id="fileUploadInput" name="files" multiple
accept="text/xml" data-ng-file-select="uploadFiles($files)" style="width: 40px;">
</div>
I modified it a bit and came up with this:
<label class="btn btn-default btn-file">
Upload
<input
type="file"
style="display: none;"
name="files"
multiple
data-ng-file-select="uploadModel($files)"
>
</label>
<span data-ng-file-select="uploadModel($files)" class="btn btn-primary btn-lg" role="button">Test</span>
However, the uploadModel()
function is not getting called:
$scope.uploadModel = function($files) {
alert('Uploading ' + $files);
}
How can I make this work in order to upload a file?
Dependencies:
<!-- Dependencies -->
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/angular-file-upload/dist/angular-file-upload.min.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script>
Application modeule:
var emaApp = angular.module('emaApp', ['ui.bootstrap', 'angularFileUpload']);