4

I'm using Angular's $resource to upload a file. I need to set the encoding to mulipart/form-data, but I can't find anyway to set enctype in $resource.

Is that possible? In other words can $resource be used for file uploading or do I have to go deeper and use $http, modifying the header using the config argument?

What is the right way to go about POSTing a multipart/form-data form in AngularJS?

user2782503
  • 195
  • 3
  • 7

1 Answers1

5

Have you tried doing something like this

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

Update: See this fiddle to understand how to use the update once the enctype has been change http://jsfiddle.net/cmyworld/doLhmgL6/

Chandermani
  • 42,589
  • 12
  • 85
  • 88