用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - java代码库

struts上传图片

2015-05-16 作者: java源代码大全举报

[java]代码库

                                     <tr>
                                        <td align="right">业务图片:</td>
                                         <td><input type="file" name="file" id="imgurl" style="border:1px solid #7F9DB9;"/><span class="checkts">&nbsp;&nbsp;&nbsp;&nbsp;*</span><span class="sm">&nbsp;&nbsp;&nbsp;&nbsp;说明:游戏图片</span><br/></td>                                  
                                   </tr>
 
<font color="#e78608">------解决思路----------------------</font>
 
你可以在system.properties中定义你的路径名
TempFilePath = C:\\1\\
RealFilePath = C:\\2\\
 
String filepath =  PropertyUtil.getProperty("TempFilePath");
        String drcPath = filepath+compid+File.separatorChar;     
        File drcpath = new File(drcPath);
        File file =new File(drcPath+ this.getUploadFileName());
           if(!drcpath.exists()){
                    drcpath.mkdirs();
 
                }
           if(!file.exists()){
               02Service.copy(this.upload, file);
            //   file.delete();
           }
        
        return SUCCESS;
public void copy(File src, File dst){
         
        try
           InputStream in = null
           OutputStream out = null
            try {                 
               in = new BufferedInputStream( new FileInputStream(src), Ass02Constant.BUFFER_SIZE); 
               out = new BufferedOutputStream( new FileOutputStream(dst), Ass02Constant.BUFFER_SIZE); 
                byte [] buffer = new byte [Ass02Constant.BUFFER_SIZE]; 
                while (in.read(buffer) > 0 ) { 
                   out.write(buffer); 
              }  
           } finally
                if ( null != in) { 
                   in.close(); 
               }  
                if ( null != out) { 
                   out.close(); 
               }  
          }
         
         
       } catch (Exception e) {
          e.printStackTrace(); 
      }
      
  }
 
 //源代码片段来自云代码http://yuncode.net
            


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...