I use input type="file"
to make form input.
I had no constraints in insert
but I have a problem in edit or update data. To get data from files that are already input. Showing filename
if I click button edit
. Can you help me ? How to get filename and show in side input type file ? Thanks.
This is my input type="file"
<div class="form-group">
<label class="control-label col-md-3">Image</label>
<div class="col-md-6">
<input type="file" name="file" file-model="userfile">
</div>
</div>
This is my directives
app.directive('fileModel', ['$parse', function ($parse) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var model = $parse(attrs.fileModel);
var modelSetter = model.assign;
element.bind('change', function(){
scope.$apply(function(){
modelSetter(scope, element[0].files[0].name);
});
});
}
};
}]);