public String fileUp(MultipartFile upfile ,HttpServletRequest request)
    {
        String pathName = "/resources/up";
        String path = "C:\\spring\\sts\\spring_mvc_06\\src\\main\\webapp"+pathName;
        String fileName = upfile.getOriginalFilename();

        File file = new File(path+"\\"+fileName);

        String newfileName="";

        int no=1;

        if(file.exists())
        {    
            while(true)
            {    
                newfileName=fileName.split("[.]")[0]+"("+no+")"+fileName.split("[.]")[1];

                if(new File(path+"\\"+newfileName).exists())
                {
                    no++;
                }
                else
                {
                    break;
                }

            }

            fileName=newfileName;

            file = new File(path+"\\"+fileName);

        }

        try 
        {
            byte [] arr = upfile.getBytes();

            FileOutputStream fos = new FileOutputStream(file);

            fos.write(arr);

            fos.close();
           

        } catch (IOException e) {

            // TODO Auto-generated catch block
            e.printStackTrace();

        }
  
        return fileName;

    }