I'm using Angular File Manager In My current Angularjs App.
I want to show an error(like: file name exist) to user when upload a file with name exist in a directory.
$scope.uploadFiles = function () {
/******* I added these ↓↓↓ ********/
var item = $scope.singleSelection();
if (item) {
var name = item.tempModel.name.trim();
var nameExists = $scope.fileNavigator.fileNameExists(name);
if (nameExists && validateSamePath(item)) {
// this name is exist, so ↓
$scope.apiMiddleware.apiHandler.error = $translate.instant('error_invalid_filename');
return false;
}
}
/******* these code are exist before(your code) ↓↓↓ ********/
$scope.apiMiddleware.upload($scope.uploadFileList, $scope.fileNavigator.currentPath).then(function () {
$scope.fileNavigator.refresh();
$scope.uploadFileList = [];
$scope.modal('uploadfile', true);
}, function (data) {
var errorMsg = data.result && data.result.error || $translate.instant('error_uploading_files');
$scope.apiMiddleware.apiHandler.error = errorMsg;
});
}
But in this case, I should to select an item then upload a file, means that, If I don't select a file and upload a new file with same name, error not appear.
I need to detect with current file fileName that uploaded
How Can I Achieve This? Thanks in advance