2017-06-22 53 views
-2

我是角2中的新角色。我使用ng2-uploder上傳文件。文件成功上載,但其顯示控制檯下面的錯誤我:角2使用ng2-uploader上傳文件

ERROR TypeError: _this.files.filter is not a function 
    at ng-file-select.ts:41 
    at SafeSubscriber.schedulerFn [as _next] (core.es5.js:3840) 
    at SafeSubscriber.__tryOrUnsub (Subscriber.js:236) 
    at SafeSubscriber.next (Subscriber.js:185) 
    at Subscriber._next (Subscriber.js:125) 
    at Subscriber.next (Subscriber.js:89) 
    at EventEmitter.Subject.next (Subject.js:55) 
    at EventEmitter.emit (core.es5.js:3814) 
    at XMLHttpRequest.xhr.onreadystatechange (ng2-uploader.ts:103) 
    at XMLHttpRequest.wrapFn [as __zone_symbol___onreadystatechange] (zone.js:1199) 
    at ZoneDelegate.webpackJsonp.1218.ZoneDelegate.invokeTask (zone.js:398) 
    at Object.onInvokeTask (core.es5.js:4116) 
    at ZoneDelegate.webpackJsonp.1218.ZoneDelegate.invokeTask (zone.js:397) 
    at Zone.webpackJsonp.1218.Zone.runTask (zone.js:165) 
    at XMLHttpRequest.ZoneTask.invoke (zone.js:460) 
+0

我們不能真正幫助你無需代碼。我的第一個猜測是你的'files'屬性不是一個數組。試着用'console.log'來看看究竟是什麼。 – trichetriche

回答

0

在這裏,我得到了我的問題的解決方案:

Instead of using ng2-uploader, i used ngx-uploader: 
First install using "sudo npm add ngx-uploader" , 
then using below link as it is: 
    "https://github.com/jkuri/ngx-uploader#backend-example-using-express" 
    It is working perfectly for me.