html上传图片到服务器

img.src = 'data:image/png;base64,' + s;html页面这种形式怎么上传到服务器

把src中的base64的数据传到后台 在后台获取 最后用流写入

String path = request.getParameter("img");

 if(path.indexOf("data:image/png;base64,") != -1){
     path = path.replace("data:image/png;base64,", ""); 

     // Base64解码 
     Decoder decoder = Base64.getDecoder();
     byte[] b = decoder.decode(path); 
     for (int i = 0; i < b.length; ++i) { 
         if (b[i] < 0) {// 调整异常数据 
             b[i] += 256; 

         }
     }
    OutputStream out = new FileOutputStream("写图片保存的路径");

     out.write(b);

将文件用流发送给后台,注意解析时编码要保持一致。