javascript - How to append a Blob to FormData - Stack Overflow

var myBlob = new Blob(["This is my blob content"], {type : "textplain"});var fd =

var myBlob = new Blob(["This is my blob content"], {type : "text/plain"});
var fd = new FormData();
fd.append("clip",myBlob)

The Blob is working fine:

myBlob: Blob
size: 341746
type: "text/plain"

But it is not being appended to the FormData:

Why is the Blob not showing up in the FormData ?

var myBlob = new Blob(["This is my blob content"], {type : "text/plain"});
var fd = new FormData();
fd.append("clip",myBlob)

The Blob is working fine:

myBlob: Blob
size: 341746
type: "text/plain"

But it is not being appended to the FormData:

Why is the Blob not showing up in the FormData ?

Share Improve this question edited Jul 28, 2020 at 20:33 WestCoastProjects asked Jul 28, 2020 at 20:30 WestCoastProjectsWestCoastProjects 63.4k106 gold badges365 silver badges627 bronze badges 2
  • fd.append('clip', myBlob, 'blobby.txt'); By the way, localStorage properties cast to Strings when possible. – StackSlave Commented Jul 28, 2020 at 20:31
  • @StackSlave I just copied and pasted incorrectly from my code : that was actually there .. Corrected the question to show it. What is the importance of your localStorage / strings ment? – WestCoastProjects Commented Jul 28, 2020 at 20:34
Add a ment  | 

1 Answer 1

Reset to default 4

Well, actually, according to FormData specs, there is no way to inspect form data elements within a simple console.log() or debugger.

So the only way to inspect the items within it is to iterate through its entires like this:

var myBlob = new Blob(["This is my blob content"], {type : "text/plain"});
var fd = new FormData();
fd.append("clip",myBlob);

// Display the key/value pairs
for (var pair of fd.entries()) {
    console.log(pair[0]+ ', ' + pair[1]); 
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745421229a4626971.html

相关推荐

  • javascript - How to append a Blob to FormData - Stack Overflow

    var myBlob = new Blob(["This is my blob content"], {type : "textplain"});var fd =

    5小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信