h5 + accessories with token upload: plus.uploader.createUpload

// mainUrls = need to upload the url
var = Task plus.uploader.createUpload (mainUrls, {
Method,: "POST",
// "note," there can not be like ajax, like the token on here.
// beforeSend: function (Request) {
// request.setRequestHeader (tokenHeader, APPTOKEN);
//},
// "request type"
headers: {
"the Content-the type": "multipart / form-Data"
}
},
function (Data, Status) {
// uploaded
IF (Status == 200 is) {
the console.log ( "Success the Upload:" + data.responseText);
} the else {
Alert ( "the Upload failed:" Status +);
}
}
);
// "note" token with toke should write in setRequestHeader when uploading attachments.
task.setRequestHeader ( "tokenHeader", "appToken ");

task.addFile (ImagesRF Royalty Free, {
key:. "File" // key name here to upload pictures
});
/ *
// upload multiple pictures (see in what way the background needed) files as a picture url array
// and more Upload images corresponding to the plurality of key
for (var I = 0; I <files.length; I ++) {
var imgpath = Files [I];
// the console.log ( "ready to upload the image path:" + imgpath);
Task .addFile (imgpath, {
key: // File File for the key picture
});
}

            //多张图片对应单个key上传
            task.addFile(files, {
                key: "file"  //这里为需要上传图片的key名称。
            });
*/

            //需要提交的参数多次添加
            task.addData("fileFrom", "信息发布");
            task.addData("attachType", "1"); 
            //开始上传
            task.start();

Guess you like

Origin blog.51cto.com/11657004/2426961