Я пытаюсь загрузить файл xlsx, используя тег ввода type = "file",
<div class="innerCnt fill" ng-app="ExcelImport" ng-controller="excelImportCtrl">
<div class="row">
<label for="fileToUpload">Select a File to Upload</label><br />
<input type="file" id="fileToUpload" multiple class="fileUploadSelector" on-file-change="addFiles" />
</div>
<h4 id="uploadStatusLabel" class="uploadStatusLabel"></h4>
<div id="uploadExcelStatusGrid">
<table class="table-striped" ng-hide="!files[0]">
<thead>
<tr>
<th>File name</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="file in files">
<td class="centerCell"><div>{{file.name}}</div></td>
<td class="centerCell"><div>{{file.status || 'Waiting for upload'}}</div></td>
<td class="centerCell"><div><a href="#" ng-if="!file.status" ng-click="removeFile($index)">Delete</a></div></td>
</tr>
</tbody>
</table>
</div>
<input type="button" id="excelUploadButton" class="button blueBtn" ng-click="uploadFiles()" value="Upload" ng-disabled="excelUploading || !files[0]"/>
</div>
Это файл ts:
appImport.directive('onFileChange', function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
var onChangeHandler = scope.$eval((attrs as any).onFileChange);
element.bind('change', function () {
scope.$apply(function () {
var files = (element[0] as any).files;
if (files) {
onChangeHandler(files);
}
});
});
}
};
});
Вот addfiles fn:
class ImportController {
private scope: any;
constructor($scope: ng.IScope) {
this.scope = $scope as any;
this.scope.files = []
this.scope.addFiles = files => this.addFiles(files)
this.scope.removeFile = idx => this.removeFile(idx);
}
private addFiles(files: FileList) {
for (var i = 0; i < files.length; i++) {
this.scope.files.push(files.item(i))
}
}
private removeFile(entryIdx: number) {
this.scope.files.splice(entryIdx, 1)
}
}
appImport.controller("excelImportCtrl", ImportController)
Как только я просматриваю файл в IE, я открываю файл в Excel и делаю некоторые изменения, после сохранения файла временный файл будет создан в той же директории.
Временной файл будет удален после закрытия приложения.
Я пытаюсь выполнить тот же процесс с Chrome, но нет временного файла.
Может кто-нибудь помочь мне, как избавиться от этого временного файла с помощью IE?
Заранее спасибо