Enctype designation in AngularJS using ngResource

I am using Angular $ resource to upload a file. I need to set the encoding to mulipart / form-data, but I still cannot set enctype to $ resource.

Is it possible? In other words, can I use $ resource to upload files, or do I need to go deeper and use $ http, changing the header using the config argument?

What is the correct way to use POSTing form multipart / form-data in AngularJS?

+4
source share
1 answer

Have you tried doing something like this

$resource( url, {}, { upload: { method: 'POST', headers: {enctype:'multipart/form-data'} }, } ) 

Update: see this script to understand how to use the update after changing the enctype http://jsfiddle.net/cmyworld/doLhmgL6/

+4
source

Source: https://habr.com/ru/post/1502334/


All Articles