Do the project with the image upload, encountered a good written by others, plug-in small, convenient, in this write a save convenient later use again
var u1 = new Uploadpic ();
U1.init ({
selector: ' #fileImage ',
Callback:function (base64,input,u) {
$.ajax ({ url:baseurl+ '/api/v1/file/uploadbase64file ',
Data: {imagefile:base64, FileType: ' 0 ', CType: ' Local ', ' base64 ': ' base64 ', ' filename ': u.filename},
Type: ' Post ',
DataType: ' JSO N ',
Success:function (i) {
alert (i.data);
var texthtml = " ';
$ ("#showImg"). Append (texthtml);
//input.prev (). Prev (). remove ();
//input.prev (). attr (' src ', i.data). CSS (' Display ', ' block ');;
//input.next (). Val (I.key);
//jq.show_tip (' Upload succeeded! ');
}
})
},
Loading:function () {
//jq.show_tip (' Upload! ');
}
});
Add-On and original address: Https://github.com/lunnlew/wx_upload_by_file
Front-end picture upload