{
// 上传类型
type: 'ajax' || 'sock',
// 分片大小单位:kb
size: 1024,
// 上传服务地址
url: ''
}
var upload = new fileUpload({
url:'wss://127.0.0.1:8055/',
type:'sock',
// 单位kb
size: 1024
});
upload.config({
url:'http://127.0.0.1:8055/test.php',
type:'ajax',
});
upload.addfile(new File(["one"], "one.txt", {type: "text/plain",}))
upload.addfile(new File(["two"], "two.txt", {type: "text/plain",}))
...
// 监听
upload.on('progress',function(FileInfo, FileList , progress){
// code
})
//开始
upload.start()
// node
base:>node ./main
base:>服务成功开启端口为:7096
base:>请访问:http://localhost:7096/example/page/index.html
base:>node service 服务启动成功 端口 3000
根目录
├─ example
│ ├─ assets //文件资源
│ ├─ page //页面
│ ├─ service //后台服务
├─ fileUpload.js //核心
└─ main.js //node 入口文件