Hello, Sanders
Thanks for getting back to me.
Actually I got it working using the *FormData()* object. Unfortunately the
FormData() is not available in IE9. Now what is really causing an issue is
not uploading file(s), but uploading files in IE9.
I am pretty sure it doesn't have to do with file size since I am testing
with small files, and as mentioned above I am able to upload files to the
server in versions higher than IE 9.
In non IE 9 browsers (Chrome, Firefox, IE >= 10) this piece of code works:
*fd = new FormData(); // FormData doesn't work in IE 9*
*fd.append('file', file);*
*//call api*
*$http({ *
* method: 'POST', *
* url: 'upload-to-this-api',*
* params: {*
* ''param1': paramValue1,*
* },*
* data: data, *
* transformRequest: angular.identity,*
* headers: {*
* 'Content-Type': undefined*
* }*
*})*
*.success(function(data, status){*
*})*
*.error(function(data, status){*
*});*
Do you happen to know what can be a good replacement for the FormData()
object in IE 9?
Thank you, and please let me know if you require more details.
PS: I got my solution from this post:
*https://uncorkedstudios.com/blog/multipartformdata-file-upload-with-angularjs
<https://uncorkedstudios.com/blog/multipartformdata-file-upload-with-angularjs>*
---------- Forwarded message ----------
From: Sander Elias <[email protected]>
Date: 2015-08-10 20:24 GMT-07:00
Subject: [AngularJS] Re: angularjs POST request gets stuck in OPTIONS and
file upload using $http POST
To: AngularJS <[email protected]>
Hi Jake,
Does it really get stuck, or is it just uploading a large file?
If I have (multiple) files I want to upload I usually use the browsers FormData
<http://t.sidekickopen18.com/e1t/c/5/f18dQhb0S7lC8dDMPbW2n0x6l2B9nMJW7t5XZs2BgLPgN2B84bbRYygTW4X9JQW56dT6Zf1JWmXg02?t=https%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FAPI%2FFormData%2FFormData&si=5294421448327168&pi=1636c539-7e54-4f0a-9b6f-90faf405c792>helper.
and then feed it to $http like this. I believe I got this solution out of
this group a long time ago ;)
var payload = new FormData();
// put binary data in your payload here.
$http.post(postUrl, payload, {
headers: { 'Content-Type': undefined},
transformRequest: function(data) { return data; }
});
Is this what you where looking for?
Regards
Sander
--
You received this message because you are subscribed to a topic in the
Google Groups "AngularJS" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/angular/KXVWr0eXX1g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
[email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
--
JAKE KWON +1 (604) 655 3109
email: [email protected]
- My linkedIn
<http://t.sidekickopen18.com/e1t/c/5/f18dQhb0S7lC8dDMPbW2n0x6l2B9nMJW7t5XZs2BgLPgN2B84bbRYygTW4X9JQW56dT6Zf1JWmXg02?t=http%3A%2F%2Fca.linkedin.com%2Fpub%2Fjake-kwon%2F97%2F9aa%2F727%2F&si=5294421448327168&pi=1636c539-7e54-4f0a-9b6f-90faf405c792>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.