梦幻之旅

DEBUG - 天道酬勤

   :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  671 随笔 :: 6 文章 :: 256 评论 :: 0 Trackbacks
/** 上传文件 */
    
private File upload;
    
    
/** 上传类型 */
    
private String uploadContentType;
    
    
/** 上传文件名 */
    
private String uploadFileName;
    
    
/** 文件上传服务 */
    
private ImportFileService importFileService;
    
    
/**
     * <ul>
     * <li>Description:[上传文件]</li>
     * <li>Created by [Huyvanpull] [2010-8-2]</li>
     * <li>Midified by [修改人] [修改时间]</li>
     * </ul>
     * 
     * 
@return
     
*/

    
public String uploadFile()
    
{
        UploadFileRes res 
= null;
        
        
try
        
{
            
// 保存文件路径
            String filePath = ServletActionContext.getServletContext()
                    .getRealPath(
"/importmgr/tempUploadFileDir");
            filePath 
+= "\\" + uploadFileName;
            
            UploadFileReq req 
= new UploadFileReq();
            req.setUploadFile(upload);
            req.setServerFilePath(filePath);
            req.setUploadFileName(uploadFileName);
            
            res 
= this.getImportFileService().uploadFile(req);
        }

        
catch (Exception ex)
        
{
            ex.printStackTrace();
            res 
= new UploadFileRes();
            res.setResCode(
-1);
            res.setMessage(
"上传文件失败");
        }

        
        
this.outXMLString(res.toXML());
        
        
return null;
    }
posted on 2010-08-02 18:24 HUIKK 阅读(211) 评论(0)  编辑  收藏 所属分类: Java

只有注册用户登录后才能发表评论。


网站导航: