The following code is working properly. Open the " https://wiki.epfl.ch/ " page in Google Chrome and execute this code in the developer console. Note: the page https://wiki.epfl.ch/test.php "does not exist and therefore does not load, but this is not a problem.
response = await fetch(""https:
response.text().then(function(content) {
formData = new FormData();
console.log(content.length);
console.log(content);
formData.append("content", content);
fetch("https://wiki.epfl.ch/test.php", {method: 'POST', body: formData});
})
He writes:
content.length: 57234
content: %PDF-1.3
%
4 0 obj
<< /Length 5 0 R /Filter /FlateDecode >>
stream
x K F ;ยข
...
Go to the "Developer Network" tab, select the "test.php" page, go to "Requested Payload:" and you can see this content:
------WebKitFormBoundaryOJOOGb7N43BxCRlv
Content-Disposition: form-data; name="content"
%PDF-1.3
%
4 0 obj
<< /Length 5 0 R /Filter /FlateDecode >>
stream
...
------WebKitFormBoundaryOJOOGb7N43BxCRlv
, (PDF), "". 57234 , ( wget) 60248 .
: ?
response.text() response.blob() :
response = await fetch("https://wiki.epfl.ch/lapa-studio/documents/DTS/laser%20tutorial.pdf");
response.blob().then(function(content) {
console.log(content.size);
console.log(content);
formData = new FormData();
formData.append("content", content);
fetch("https://wiki.epfl.ch/test.php", {method: 'POST', body: formData});
})
:
content.size: 60248
content: Blob(60248) {size: 60248, type: "application/pdf"}
, " ", "test.php" , " :" , , :
------WebKitFormBoundaryYoibuD14Ah2cNGAd
Content-Disposition: form-data; name="content"; filename="blob"
Content-Type: application/pdf
------WebKitFormBoundaryYoibuD14Ah2cNGAd--
. -, , wiki.epfl.ch. , ( Cross-Origin). "test.php" php, $_POST['content'] response.text(), response.blob() . , , " " " :" , .
: ?