想请教一下上传完图片后,jfinal后台怎么对这个图片进行改名?
String uploadFileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date(System.currentTimeMillis())); int maxSize = 10 * 1024 * 1024; //上传文件大小10M //获得上传文件 UploadFile uploadFile = getFile("u_image","",maxSize,"UTF-8"); //获得源文件文件名 String fileName = uploadFile.getFileName(); //得到源文件的后缀 String extension = fileName.substring(fileName.lastIndexOf(".")); //文件保存名(到数据库) String imgSrc=uploadFileName+extension; //文件更名 File file = new File("/upload/temp/"+fileName); if(file.exists()) { file.renameTo(new File("/upload/temp/"+imgSrc)); }这是我写的,只能把图片保存到这个upload/temp/文件夹里面,名字还是没有改。@jfinal
项目:JFinal