HTML5 文件API(一)
1.FileList对象与File对象

2.文件API之Bolb对象
A Blob object represents a file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system.
To construct a Blob from other non-blob objects and data, use the Blob() constructor. To create a blob that contains a subset of another blob's data, use the slice() method. To obtain a Blob object for a file on the user's file system, see the File documentation.
The APIs accepting Blob objects are also listed on the File documentation.
Constructor
Blob(blobParts[, options])
Returns a newly created Blob object whose content consists of the concatenation of the array of values given in parameter.
Properties
Blob.isClosed Read only  
A boolean value, indicating whether the Blob.close() method has been called on the blob. Closed blobs can not be read.
Blob.size Read only
The size, in bytes, of the data contained in the Blob object.
Blob.type Read only
A string indicating the MIME type of the data contained in the Blob. If the type is unknown, this string is empty.
Methods
Blob.close() 
Closes the blob object, possibly freeing underlying resources.
Blob.slice([start[, end[, contentType]]])
Returns a new Blob object containing the data in the specified range of bytes of the source Blob.
Examples
Blob constructor example usage
The Blob() constructor allows one to create blobs from other objects. For example, to construct a blob from string:
var debug = {hello: "world"};
var blob = new Blob([JSON.stringify(debug, null, 2)], {type : 'application/json'});
Before the Blob constructor was available, this could be accomplished through the BlobBuilder API, which is now deprecated:
var builder = new BlobBuilder();
var fileParts = ['<a id="a"><b id="b">hey!</b></a>'];
builder.append(fileParts[0]);
var myBlob = builder.getBlob('text/xml');
Example for creating a URL to a typed array using a blob
The following code:
var typedArray = GetTheTypedArraySomehow();
var blob = new Blob([typedArray], {type: 'application/octet-binary'}); // pass a useful mime type here
var url = URL.createObjectURL(blob);
// url will be something like: blob:d3958f5c-0777-0845-9dcf-2cb28783acaf
// now you can use the url in any context that regular URLs can be used in, for example img.src, etc.
Example for extracting data from a Blob
The only way to read content from a Blob is to use a FileReader. The following code reads the content of a Blob as a typed array.
var reader = new FileReader();
reader.addEventListener("loadend", function() {
   // reader.result contains the contents of blob as a typed array
});
reader.readAsArrayBuffer(blob);
By using other methods of FileReader, it is possible to read the contents of a Blob as a string or a data URL.

间断上传文件的格式

3.文件API之FileReader对象
http://blog.csdn.net/zk437092645/article/details/8745647
HTML5 文件API(一)的更多相关文章
- 用html5文件api实现移动端图片上传&预览效果
		
想要用h5在移动端实现图片上传&预览效果,首先要了解html5的文件api相关知识(所有api只列举本功能所需): 1.Blob对象 Blob表示原始二进制数据,Html5的file对象就继 ...
 - HTML5文件API之FileReader
		
在文件上传之前,我们总想预览一下文件内容,或图片样子,html5 中FileReader正好提供了2种方法,可以在不上传文件的情况下,预览文件内容. 图片预览:readAsDataURL(file); ...
 - HTML5文件API
		
File对象与File对象 Blob对象 FileReader对象 File对象 <!DOCTYPE html> <html> <head> <meta ht ...
 - HTML5 文件API(二)
		
1.FileSystem概述及浏览器检 2.申请磁盘配额 3.创建文件
 - HTML5 文件API
		
filelist 表示文件对象的列表. <form name="upload"> <input type="file" name=" ...
 - Resumable.js – 基于 HTML5 File API 的文件上传
		
Resumable.js 是一个 JavaScript 库,通过 HTML5 文件 API 提供,稳定和可恢复的批量上传功能.在上传大文件的时候通过每个文件分割成小块,每块在上传失败的时候,上传会不断 ...
 - HTML5权威指南--标签新变化,文件API,拖放API(简要学习笔记一)
		
1.标签元素更加语义化 2.内容类型仍然为“text/html” 扩展符仍然为html或者htm. <1>DOCTYPE 声明<!DOCTYPE html>就可 ...
 - HTML5 File API — 让前端操作文件变的可能
		
前言 在 HTML5 File API 出现之前,前端对于文件的操作是非常有局限性的,大多需要配合后端实现.出于安全角度考虑,从本地上传文件时,代码不可能获取文件在用户本地的地址,所以纯前端不可能完成 ...
 - HTML5   file api读取文件的MD5码工具
		
1.工具的用途:用HTML5 file api读取文件的MD5码.MD5码在文件的唯一性识别上有很重要的应用,业内常用MD5进行文件识别.文件秒传.文件安全性检查等: 2.适用性:IE.Chrome皆 ...
 
随机推荐
- LANMP 如何禁止访问 .htaccess 文件
			
很多朋友问我,为什么他已经在 Apache 规则里面加了禁止别人直接下载 .htaccess 文件,为什么还是可以下载? 其实这个很简单,因为 .htaccess 在 LANMP 环境下,当他作为文件 ...
 - php对数组排序代码
			
php对数组排序,介绍了和php,有关的知识.技巧.经验,和一些php源码等. 对数组排序 usort() 函数使用用户自定义的函数对数组排序. */ function cmp($a, $b) //用 ...
 - Python脚本控制的WebDriver 常用操作 <十六> 处理对话框
			
下面将使用webdriver来处理一些页面跳出的对话框事件 测试用例场景 页面上弹出的对话框是自动化测试经常会遇到的一个问题.前端框架的对话框经常是div形式的,下面是一些常见的对话框操作事件: 打开 ...
 - thinkpad t440p 解决无线网卡驱动
			
$ wget https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1239578/+attachment/4057550/+files/rtl_9 ...
 - android架构介绍
			
Android其本质就是在标准的Linux系统上增加了Java虚拟机Dalvik,并在Dalvik虚拟机上搭建了一个JAVA的application framework,所有的应用程序都是基于JAVA ...
 - 关于const
			
1.顶层const和底层const const修饰的对象本身是常量,则为顶层const,否则为底层const 如: const int a=10; //a是int常量,顶层const i ...
 - Elasticsearch 5.0
			
Elasticsearch 5.0 使用ES的基本都会使用过head,但是版本升级到5.0后,head插件就不好使了.下面就看看如何在5.0中启动Head插件吧! 官方粗略教程 Running wit ...
 - C语言基础:指针类型与指针和数组、字符串的关系
			
//指针变量就是用来存储地址的,只能存储地址 格式: int *p; 这个p为指针变量:指针变量占8个字节 类型是用来说明这个指针指向的类型: 比如上边的int代表这个指针变量会指向int类型的 ...
 - Careercup - Facebook面试题 - 5729456584916992
			
2014-05-02 00:59 题目链接 原题: Given a normal binary tree, write a function to serialize the tree into a ...
 - 用C#进行WinForm开发对数据库的相关操作
			
class SQLHelper { public SqlConnection conn; //<summary> //链接.打开数据库 //</summary> public ...