Вопрос

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?

Это было полезно?

Решение

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/

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top