How to upload image along with other data in AngularJS

I am newbie in AngularJS and learning login/registring functionality in AngularJS from http://www.angularcode.com/user-authentication-using-angularjs-php-mysql/ tutorial. In this tutorial there is no image upload functionality in signup, and I want to upload image along with other information. How will I do it !?

Thanks in advance


Basically, you have two choices :

  • Send the image file together with additional data.For this to work the request content type should be multipart/form-data.
    Look at : http://shazwazza.com/post/Uploading-files-and-JSON-data-in-the-same-request-with-Angular-JS

  • Upload the image to the server ,receive its id and then send the id to the server together with the additional data.
    Look at : Posting a File and Associated Data to a RESTful WebService preferably as JSON

  • 链接地址: http://www.djcxy.com/p/48650.html

    上一篇: 使用rest api以自动方式将大文件发送到服务器的最佳方法?

    下一篇: 如何将图片与AngularJS中的其他数据一起上传