文件上传改文件名,取数据库图片

2019-04-15 13:48发布

  图片要以pic名字另存为 只要这句话 File file = su.getFiles().getFile(0);
         file.saveAs("advertiser/uploadfiles/" + pic, su.SAVE_VIRTUAL); 不要  su.save("advertiser/uploadfiles"); 显示图片 <%
 String id= request.getParameter("id");
  String pic="";
 String sql="select pic from ads_des where id="+id;
 db.creatConnection();
 ResultSet rs= db.executeQuery(sql);
  if(rs.next())
  {
  pic=rs.getString("pic");
  }
   String resource="advertiser/uploadfiles/"+pic;
   System.out.println(resource);
   db.closeConnection();
 %>