Usage of HTML5 Blob.slice() method

JavascriptWeb DevelopmentFront End Scripts

The HTML5 file Blob.slice() method is useful for creating a Blob object containing the data. This data is in the specified range of bytes of the source Blob.

Let us see an example to send and receive binary data using slice(). This example sends a text and use the POST method to send the "file" to the server:

var val = new XMLHttpRequest();"POST", url, true);
val.onload = function (event) {
var blob = new Blob(['demo'], {type: 'text/plain'});
Updated on 30-Jan-2020 07:06:34