According to this SO post the boundary value of the header Content-Type can be changed, MDN says the same too. But in my case it doesn't happen, I don't get it why.
When I inspect the console (Chrome, Firefox), the header is set correctly, as I defined it:
content-type: multipart/form-data; boundary=aBoundaryString
At the same time when I look at the request (in the console) I see data separated by ------WebKitFormBoundarymdIB1kNGNJ3dldnm
in Chrome, and some big number-boundary in Firefox.
I use PHP on server side, and in this case when I try to read request data there via var_dump(file_get_contents('php://input'))
I get result as string(0) ""
.
I have to say, that when I set the Content-Type header without "boundary", like this:
content-type: multipart/form-data
(and this is what I see in the console too), in this case the Request Payload is also separated with the same browser boundaries, but in this case, on the server side, request data is not empty, but as it should be and separated with same boundaries which I see in browser console.
So what's the problem, why can't I change the boundary? I mean it's definitely set, because I see that in the header Content-Type, but why isn't it applied to the request?
Screenshots from the Firefox v100 console
first 3 images is a request without boundary value
next 3 images is a request with boundary value
there's no difference if the file (uploads) is attached or not, result the same; and as I said in Chrome result the same
request sent via XMLHttpRequest
, headers set by setRequestHeader()
Update
Okay, I've made my data to get to the server even with "boundary". For that I added "
to the value, now it's like this:
content-type: "multipart/form-data; boundary=aBoundaryString"
before was like this:
content-type: multipart/form-data; boundary=aBoundaryString
BUT! The the boundary is still not applied, the Request Payload is still has browser's boundary, not mine. I've also printed $_SERVER["CONTENT_TYPE"]
and there's "multipart/form-data; boundary=aBoundaryString". What's the problem?