0
剣道とAngularJSでファイルをアップロードすることができますが、ファイルは赤色でk-ファイルエラークラスがあり、ファイルがアップロードされています。 。なぜエラーがありますか?手伝っていただけませんか ?剣道アップロードが成功したときのk-file-error
<div class="demo-section k-content">
<div>
<h4>Upload files</h4>
<div class="dropZoneElement">Drag and drop file here</div>
<input name="files"
ng-model="vm.files"
type="file"
kendo-upload
k-async="{ saveUrl: 'http://localhost:5000/api/upload/', removeUrl: 'remove', autoUpload: true, withCredentials: false }"
k-select="onSelect"
k-upload="onUpload"
k-progress="onProgress"
k-success="onSuccess"
options="vm.options"
/>
</div>
<button ng-click="vm.test()">Test</button>
</div>
class DocumentController {
/* @ngInject */
constructor($scope, authTokenService) {
this.name = 'document';
$scope.onSelect = e => {
// console.log(e.files);
};
$scope.onUpload = e => {
const token = authTokenService.getToken();
// Check if the token is expire
if (token && authTokenService.isExpired(token)) {
authTokenService.setToken();
}
const xhr = e.XMLHttpRequest;
if (xhr) {
xhr.addEventListener('readystatechange',() => {
if (xhr.readyState === 1) {
// Add the token to the header
if (token) {
xhr.setRequestHeader('Authorization', `Bearer ${token}`);
}
}
});
}
};
$scope.onSuccess = e => {
console.log(e);
};
$scope.onProgress = e => {
// console.log(e);
};
this.options = {
dropZone: '.dropZoneElement'
};
}
}
export default DocumentController;
あなたのサーバーアクション(http:// localhost:5000/api/upload)は何を返していますか?すべてのアップロードデモには次のようなものがあります: "//成功を意味する空の文字列を返します" –