问题是:在Servlet中获取页面文本框里面图片的路径。在存入数据库中
    请大家帮帮忙

解决方案 »

  1.   

    那要去下个jar包,smartupload
    百度下就有了
      

  2.   

    我觉得楼主先应该想清楚要在Mysql中存路径字符串还是存Blob对象?
      

  3.   

    不至于说在数据库中存图片吧?用blob对象存?
    为什么不直接存上传后的路径捏.:(
    package com.hmilyld.exp.mysql;import java.io.File;
    import java.io.FileInputStream;
    import java.io.InputStream;
    import java.sql.Connection;
    import java.sql.PreparedStatement;public class InsertBLOB { /**
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
    Connection conn = ConnectionManage.getConnection();
    String sql = "insert into testimage(image) values(?)";
    PreparedStatement stm = conn.prepareStatement(sql);
    File file = new File("c:\\aaa.gif");
    InputStream photoStream = new FileInputStream(file);
    stm.setBinaryStream(1, photoStream, (int)file.length());
    stm.executeUpdate();
    ConnectionManage.closeConnection(conn, null, null);
    }
    }
      

  4.   

    额,楼主的意思好像是要存地址进去,
    用smartUpload上传,然后获得上传后的路径,存入数据库就OK了.
    具体的,楼主GG下SmartUpload就能找到了,很多例子的.