【问题标题】:File API: Returns file reference (object) or whole file content (string)?文件 API:返回文件引用(对象)或整个文件内容(字符串)?
【发布时间】:2010-11-28 03:41:56
【问题描述】:

在plupload(plupload.html5.js)中,我看到了这段代码:

// Blob is string so we need to fake chunking, this is not
// ideal since the whole file is loaded into memory
if (typeof(blob) == 'string') {
    chunkBlob = blob.substring(chunk * chunkSize, chunk * chunkSize + curChunkSize);
} else {
    // Slice the chunk
    chunkBlob = blob.slice(chunk * chunkSize, curChunkSize);
}

我想知道那个 blob 是否可以是一个字符串?正如我从源代码中看到的那样,blob 变量应该包含(我认为它应该包含)对用户选择的文件的文件引用,所以它表达了这样的内容:

<input type="file" onchange="var thatBlob = this.files[0]" />

从 cmets 我看到它可能会返回整个文件内容而不是对其的引用。怎么会?

有什么我不明白的地方吗?

【问题讨论】:

    标签: javascript html file-upload fileapi


    【解决方案1】:

    好的,我错过了他们也使用 getAsBinary() (返回字符串)。

    【讨论】:

      猜你喜欢
      • 2019-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多