新手求教,再做一个自定义上传头像问题,现在是前端可以获得手机上的照片后也能正常显示到ui上,但是还没有把图片发给服务器,求各位大神给个思路,我用的是短连接,应该怎么给服务器发呢?发什么呢?新手小菜一枚,求解!服务器给我说不推荐我发64位码(下面的代码是我从手机获得图片后给显示到ui上的代码)
idGetBase64StringToImage: function (sss) {
var that = this;
var base64String;
that.id = “head”;
var fileName = jsb.fileUtils.getWritablePath() + that.id + “.jpg”;
base64String = sss;
// 生成图片
if (cc.sys.os === cc.sys.OS_ANDROID) {
jsb.reflection.callStaticMethod("org/cocos2dx/javascript/ImagePicker", "base64ToFile",
"(Ljava/lang/String;Ljava/lang/String;)V", base64String, fileName);
} else if (cc.sys.os === cc.sys.OS_IOS) {
jsb.reflection.callStaticMethod("ImagePickerViewController", "base64StringToFile:fileName:",
base64String, fileName);
} else {
jsb.fileUtils.saveBinaryFile(base64String, fileName); // 有了这个无需前两个
}
cc.loader.load(fileName, function (err, tex) {
cc.loader.release(fileName);
that.newframe = new cc.SpriteFrame(tex);
that.head.spriteFrame = that.newframe;
//that.head.spriteFrame.setTexture(tex);
});