起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1951|回复: 1

[处理中3] 拍照上传C#后台

[复制链接]

55

主题

65

帖子

231

积分

中级会员

Rank: 3Rank: 3

积分
231
QQ
发表于 2017-1-14 10:09:22 | 显示全部楼层 |阅读模式
本帖最后由 xwfsales 于 2017-1-15 10:28 编辑

急需拍照上传demo ,要求c#(.net后台 ,action )  后台,,请发demo ,源码  QQ70167460  跪求
也就是将下面的 java 的后台,改为 c#(.net) 后台:请高手指导

附:


然后是,后台对应的图片上传baas,将图片保存在UI2/myClassmate/uploadfiles目录下,这里可以自己进行调整:
public static JSONObject uploadPicfile(JSONObject params, ActionContext context) throws SQLException, NamingException, IOException {
                        
                         System.out.println("uploadPicfile is running...");
                        
                        String ownerID = params.getString("ownerID");
                        String storeFileName = params.getString("storeFileName");                        
                        String picData = params.getString("picData");   


             String baasPath = Thread.currentThread().getContextClassLoader().getResource("").getPath()  ;
             String docStorePath = baasPath + ".." + File.separator + ".."+ File.separator + "model" +File.separator + "UI2" +File.separator + "myClassmate" +File.separator+"uploadfiles" ;
             File docstoreDir = new File(docStorePath);
                   if(!(docstoreDir.exists() && docstoreDir.isDirectory())){
                          docstoreDir.mkdirs();
                   }                           

            String storePath = docStorePath + File.separator + ownerID;
                 File storeDir = new File(storePath);
                 if(!(storeDir.exists() && storeDir.isDirectory())){
                         storeDir.mkdirs();
                 }      
                 
                System.out.println("后台计算的baasPath的值:"+ baasPath);
           System.out.println("后台计算的docStorePath的值:"+ docStorePath);  
           System.out.println("后台计算的storeDir的值:"+ storeDir);

             BASE64Decoder decoder = new BASE64Decoder();
             try {                  
                     byte[] decodedBytes = decoder.decodeBuffer(picData);

                     String imgFile = storePath + File.separator + storeFileName;
                     FileOutputStream out = new FileOutputStream(imgFile);
                     out.write(decodedBytes);
                     out.close();
                     System.out.println("图片上传成功!");
             } catch (Exception e) {
                     System.out.println("图片上传失败!");
                     e.printStackTrace();
             }
             return null;
     }

发表于 2017-1-16 10:33:04 | 显示全部楼层
关于.net开发! 请看文档中   “服务端开发”   相关文章!
http://docs.wex5.com/net-develop-1/
qq:1912779713
WeX5教程--WeX5下载
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2025-6-27 17:52 , Processed in 0.060359 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表