Benim dosya yükleme yönetmek için https://github.com/danialfarid/ng-file-upload eklentisini kullanıyorum, aşağıdaki kodumu.Angularjs: Hata: "Append" arabirimini uygulamayan bir nesnede çağrılan 'append'. jQuery.param/add
HTML
<form name="form">
Single Image with validations
<div class="button" ngf-select ng-model="file" name="file" ngf-pattern="'image/*'"
ngf-accept="'image/*'" ngf-max-size="20MB" ngf-min-height="100"
ngf-resize="{width: 100, height: 100}">Select</div>
Multiple files
<div class="button" ngf-select ng-model="files" ngf-multiple="true">Select</div>
Drop files: <div ngf-drop ng-model="files" class="drop-box">Drop</div>
<button type="submit" ng-click="upload()">submit</button>
</form>
Kontrolör
// upload on file select or drop
$scope.upload = function (file) {
file = new FormData();
file = {'file': file};
imageFind.search(file, $scope.documentsOffsetStart, $scope.titleSorting)
.then(
function (response) {
console.log('Success ' + response.config.data.file.name + 'uploaded. Response: ' + response.data);
},
function (response) {
console.log('Error status: ' + response.status);
}, function (evt) {
console.log('progress: ' + progressPercentage + '% ' + evt.config.data.file.name);
});
};
Görüntü hizmeti bulmak
]).factory('imageFind', [
'imageService', 'ApiService',
function (imageService, ApiService) {
return {
search: function (file, start, sort) {
var formData, params={};
if (start == null) {
start = 0;
}
if (sort == null) {
sort = "";
}
var data = {
start: start,
sort: sort
};
data = $.param(data);
var config = {'Content-Type': undefined};
return ApiService.post(imageFindPint, data, config);
}
};
}
]);
Im alma aşağıdaki hata olduğunda image upload: Hata: "Append" arabirimi uygulanmayan bir nesne üzerinde çağrılan 'append'. jQuery.param/add
Görüyorsunuz, yanlış bir şey yapıyorum?
Bu kod, ng dosyası ile yükleme kullanılmamaktadır. Servis çağrısı veya bağımlılık enjeksiyonu yoktur. – danial
@danial "Upload" dependancy enjekte –
ng-file-upload ile ilgili herhangi bir kod göremiyorum – danial