routeFilesUpload.jsp
上传用户:guhaomin
上传日期:2007-06-10
资源大小:23203k
文件大小:4k
源码类别:

电子政务应用

开发平台:

Java

  1. <%       
  2.        pageContext.setAttribute("encodeFlag" , "false");     
  3.        String root = ConfigParaLoader.getParameter("rootUrl");
  4.        if( request.getParameter("type") !=null && request.getParameter("type").equals("1") ) //上传文件
  5.        {         
  6.            
  7.            
  8.            attachURL += SubPathGenerater.getSeperator() + SubPathGenerater.getSubPath( root + SubPathGenerater.getSeperator() + attachURL);
  9.            routeValueBean = ( RouteValueBean )session.getAttribute( "routeValueBean" );
  10.    //上传文件
  11.    // Initialization
  12.            mySmartUpload.initialize( pageContext );
  13.            System.out.println(" the attachmentsize===" + ConfigParaLoader.getParameter("attachmentSize") );
  14.            mySmartUpload.setTotalMaxFileSize( Integer.parseInt( ConfigParaLoader.getParameter("attachmentSize") ) );
  15.    // Upload
  16.    mySmartUpload.upload();
  17.    mySmartUpload.save( root + SubPathGenerater.getSeperator() + attachURL  );
  18.           
  19.    //保存已有信息
  20.    if( mySmartUpload.getRequest().getParameter("routeName") != null )
  21.         routeValueBean.setRouteName( mySmartUpload.getRequest().getParameter("routeName") );
  22.    if( mySmartUpload.getRequest().getParameter("description") != null )             
  23.         routeValueBean.setDescription( mySmartUpload.getRequest().getParameter("description") );    
  24.    if( mySmartUpload.getRequest().getParameterValues("stepNos") != null )
  25.         routeValueBean.setStepNos( mySmartUpload.getRequest().getParameterValues("stepNos") );
  26.    if( mySmartUpload.getRequest().getParameter("workflowTypeId") != null )             
  27.         routeValueBean.setWorkflowTypeId( Integer.parseInt ( mySmartUpload.getRequest().getParameter("workflowTypeId") ) );        
  28.         
  29.           
  30.            Collection c = routeValueBean.getRouteFiles();       
  31.            for(int i=0;i<mySmartUpload.getFiles().getCount();i++)
  32.            {
  33.                com.vnex.intranet.upload.File myFile = mySmartUpload.getFiles().getFile(i);
  34.                if (!myFile.isMissing())   
  35.                {
  36.                    WorkflowFileValueBean wf = new WorkflowFileValueBean();
  37.                    wf.setName( myFile.getFileName() ); 
  38.                    wf.setTitle( attachURL + "/" + myFile.getFileName() ); 
  39.                    wf.setDescription( myFile.getFileName() ); 
  40.                    c.add(wf);              
  41.                }                            
  42.            }         
  43.            routeValueBean.setRouteFiles(c);
  44.            session.setAttribute( "routeValueBean", routeValueBean );              
  45.        }
  46.   
  47.        if( request.getParameter("type") !=null &&  request.getParameter("type").equals("2") ) //删除文件
  48.        { 
  49.            routeValueBean = ( RouteValueBean )session.getAttribute( "routeValueBean" );
  50.    
  51.       //保存已有信息
  52.    routeValueBean.setRouteName( request.getParameter("routeName") );
  53.    routeValueBean.setDescription( request.getParameter("description") );
  54.    routeValueBean.setWorkflowTypeId(Integer.parseInt( request.getParameter("workflowTypeId") ));
  55.    routeValueBean.setStepNos( request.getParameterValues("stepNos"));
  56.            String files[] = request.getParameterValues("attachments");
  57.            if(files!= null)
  58.            {              
  59.                for(int i = 0; i<files.length; i++)
  60.                {
  61.                    SubPathGenerater.deleteFile( root + SubPathGenerater.getSeperator() + files[i] );  
  62.                    routeValueBean.removeFile(  files[i] );
  63.                    System.out.println("......routeFilesUpload.jsp: remove ok: the file size==="+routeValueBean.getRouteFiles().size());        
  64.                }     
  65.           }
  66.           session.setAttribute( "routeValueBean", routeValueBean );     
  67.       }
  68. %>