这是一个与下面这个问题非常相似的问题
以下是我检测图像粘贴事件的示例代码。
document.getElementById("imagePaste").onpaste = function (event) {
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
console.log(JSON.stringify(items)); // will give you the mime types
for (index in items) {
var item = items[index];
if (item.kind === 'file') {
var blob = item.getAsFile();
const file = new File([blob], 'test', { type: blob.type })
console.log("file.size: ", file.size);
}
}
}
Run Code Online (Sandbox Code Playgroud)
控制台日志记录file.size返回的文件大小为 500kb,而上传完全相同的文件仅为 50kb(实际图像大小为 50kb)。为什么图像的大小增加了这么多?
提前致谢!
| 归档时间: |
|
| 查看次数: |
167 次 |
| 最近记录: |