Search code examples
jqueryjquery-pluginsfileapi

jquery file uploading error


I am using a jquery plugin for uploading contents. This plugin use File api. when i use chrome there is an error show that

   Uncaught TypeError: Object #<File> has no method 'webkitSlice'.

here is the error present

    /**
 * Return the proper slice (packet)
 * @param {Number} packetId 
 * @returns {Blob} Returns a new Blob object containing the data in the specified range of bytes
 */
function getPacket(packetId){

    var startByte = packetId  * self.packetSize,
    endByte = startByte+self.packetSize,
    packet;

    if ('mozSlice' in self.file) {
        // mozilla
        packet = self.file.mozSlice(startByte, endByte);
    } else {
        // webkit
        packet = self.file.webkitSlice(startByte, endByte); // here
    }
    return packet;
}

if any one know about this please help me


Solution

  • The method webkitSlice is depracated long time ago and it's not being used anymore for that object. Try slice() instead:

    packet = self.file.slice(startByte, endByte);