Upload big files in SPA (angular + express)

三世轮回 提交于 2019-12-12 01:47:58

问题


Normal to upload file I do

<form method='post' enctype='multipart/form-data'>      
    <p><input type='text', name='name'/></p>            
    <p><input type='file', name='image'/></p>      
    <p><input type='submit', value='Wyślij'/></p>    
</form> 

What if I want send this form without page reload?

I can use "new FileReader()" and bind base64 to $scope but with big files it doesn't work well.

Can I upload my form without page reload in similar way like above?


回答1:


I think you should looked at the directive which has been created already ng-file-upload

Features

  1. Supports upload progress, cancel/abort upload while in progress, File drag and drop (html5), Directory drag and drop (webkit), CORS, PUT(html5)/POST methods.
  2. Cross browser file upload (HTML5 and non-HTML5) with Flash polyfill FileAPI. Allows client side validation/modification before uploading the file
  3. Direct upload to db services CouchDB, imgur, etc... with file's content type using $upload.http(). This enables progress event for angular http POST/PUT requests.
  4. Seperate shim file, FileAPI files are loaded on demand for non-HTML5 code meaning no extra load/code if you just need HTML5 support.
  5. Lightweight using regular $http to upload (with shim for non-HTML5 browsers) so all angular $http features are available.



回答2:


https://github.com/nervgh/angular-file-upload/ seems to handle large uploads very gracefully



来源:https://stackoverflow.com/questions/29332169/upload-big-files-in-spa-angular-express

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!