Comments (24)
Yes I can confirm your patch works fine.
Stupid IE.
from formdata.
hmm, it do look badly formatted. Could you try to dump the actual blob that are being sent using this client side code?
here is how
var blob = formdata._blob()
var fr = new FileReader
fr.onload = function() {
console.log(fr.result)
}
fr.readAsText(blob)
for me it looks something like:
------formdata-polyfill-0.24730354822730538
Content-Disposition: form-data; name="key"
value
------formdata-polyfill-0.24730354822730538--
which is correct.
Would also help if you dumped the request headers... specifically the content-type header you get in your server
from formdata.
Using the code you provided I got the following ( see the screenshot as I am testing using BrowserStack and cannot copy/paste easily ), which looks ok.
So then it's an issue on the backend side.Is that possible that the formdata-polyfill prefix is conflicting with the form entry parsing library of my current framework ?
from formdata.
Got to be a problem on the server side...
Are you using a library for parsing multipart forms?
Things you can check:
- Are the the blob size the same as
Content-Length
request header? - Are the
Content-Type
request header same as the blob's mime type?
PHP should be able to parse it $_POST["email"]
from formdata.
I'll check that ;-)
from formdata.
chromes FormData don't look much different
fd = new FormData
fd.append('key', 'value')
new Response(fd).text().then(console.log)
result = `
------WebKitFormBoundary9F5Xu977y9H9FXm0
Content-Disposition: form-data; name="key"
value
------WebKitFormBoundary9F5Xu977y9H9FXm0--
`
note: Math.random
is not always the same length
So calling fd._blob() might not be the same size when you are sending it.
so you can instead send the blob... xhr.send(blob)
from formdata.
What seems strange is that the developer tools of my IE11 borwserStack instance are not detecting anything in the request body, even though the code you gave me seems ok. See the following screen for reference.
It really looks to me that the HTTP Post is send empty.
from formdata.
I'm not sure how you can miss something like a -
, spaces
and ;
in your body. Something is stripping the content
from formdata.
Weird. try sending the blob then and see what happens... xhr.send(formdata._blob())
the content-type header is wrong, but it might also be the response content-type
and not the request content-type
the polyfill also got another trick in the sleeve, formdata = formdata._asNative()
from formdata.
mather of fact, it looks to me like you are inspecting the response body, response header & the response content-type
from formdata.
Ok on the client side I was missing the Content-Type : multipart/form-data which explains the emptyness of the request body when inspecting.
Remaining issue is on the backend side.
Thanks for your attention, I have been making some progress ;-) And your library has no issue then.
from formdata.
Was snooping around on browserstack myself when you reveled your website.
It doesn't look like the Content-Type is being set?
If you would perhaps do it like this:
var blob = formdata._blob();
xhr.open( method, url );
xhr.setRequestHeader( "X-Requested-With", "XMLHttpRequest" );
xhr.setRequestHeader( "Content-Type", blob.type );
xhr.send( blob );
would it work for you then?
from formdata.
In that case i might make a patch where i set the content-type header in the polyfill
from formdata.
I am testing.
from formdata.
The spec is: If you are sending a Blob/file with ajax and no content-type header is specified it should use the Files type as content-type. IE don't seems to follow that rule?
from formdata.
Gah, hate IE. Going to make a patch to fix it.
from formdata.
found something related: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/6047383/
from formdata.
Top ! And really thanks for your time ;-)
from formdata.
I am not that familiar with the use of Blobs so I did not look in that direction but yeah, your article seems to correspond to the situation.
from formdata.
Fixed in 3.0.6 3.0.7
from formdata.
👍
from formdata.
Tested but got an issue being:
Object doesn't support property or method 'a'
The incriminated line being:
XMLHttpRequest.prototype.send=function(b){b instanceof H&&(b=b.a(),this.setRequestHeader("Content-Type", b.type))
from formdata.
Forgot closure compiler mangels private properties/methods starting with _
Fixed in 3.0.7
from formdata.
Works perfect !
from formdata.
Related Issues (20)
- Exclude Disabled Fieldset Descendent Controls HOT 10
- in ios 10.3 formData be text/plain HOT 2
- handle empty fileList HOT 1
- IE11 empty request body HOT 6
- Not IE Safe HOT 3
- [Suggestion] Add more per-entry headers HOT 1
- Suggest adding boundary setter and getter HOT 2
- IE11 upload failing in version 4.0.1 HOT 4
- encode headers more correctly HOT 2
- run test agains WPT
- 4.0.5 is broken HOT 1
- Use Github CI HOT 1
- TypeScript types not published HOT 2
- The automated release is failing 🚨
- Is this program support IE11? HOT 3
- error TS2322: Type 'FormData' is not assignable to type 'BodyInit'. HOT 1
- Request fails while using `fs.createReadStream` HOT 3
- How to send a form with additional headers in node.js with fetch HOT 2
- Example in the readme is confusing HOT 4
- `SyntaxError: Invalid regular expression` in Safari HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from formdata.