用jspsmart组件处理上传:(你先看看在自己改改)---------------------htm---------------------------------------------------------
<html>
<head>
<title>
up
</title>
</head>
<body bgcolor="#ffffff">
<form action=upload.jsp enctype="multipart/form-data" method="post">
<p>选择文件2:<input type=file name=File2></p>
<p><input type=submit value=上传><input type=reset value=重选></p>
</form>
</body>
</html>
--------------------------------上传的jsp----------------------------------------<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="com.jspsmart.upload.*"%>
<jsp:useBean id="myjspSmart" scope="page" class="com.jspsmart.upload.SmartUpload" />
<%
  myjspSmart.initialize(pageContext);
  myjspSmart.upload();
  for(int i=0;i<myjspSmart.getFiles().getCount();i++){
    com.jspsmart.upload.File myFile=myjspSmart.getFiles().getFile(i);
    if(!myFile.isMissing()){
      myFile.saveAs("upload/"+myFile.getFileName());
    }
  }
 /* java.util.Enumeration e=myjspSmart.getRequest().getParameterNames();
  while(e.hasMoreElements()){
    String key=(String)e.nextElement();
    String[] values=myjspSmart.getRequest().getParameterValues(key);
    for(int i=0;i<values.length;i++){
      out.print(key+"="+values[i]+"<br>");
}
}*/
%>
下载嘛!你就直接写超连接到你的文件地址就行

解决方案 »

  1.   

    显示图片,你可以在上面的这个页面中要显示图片的地方这样写
    <img src="showpic.jsp?id=<%=picID%>">showpic.jsp页面根据图片ID从数据库中调出图片显示,代码如下
    <%@ page contentType="text/html; charset=gb2312"%><%
    String Id,TypeValue;
    Id=request.getParameter("Id");
    TypeValue=request.getParameter("Type");
    odbcQuery="select * from MediaLib where ID="+Id;
    odbcRs=odbcStmt.executeQuery(odbcQuery); byte[] Buffer=new byte[1024*10];
    InputStream InData=null;
    OutputStream outData=null;
    int iSize;
    if(odbcRs.next())
    {
    outData=response.getOutputStream();
    InData=odbcRs.getBinaryStream("MediaFile");
    response.setContentType(TypeValue);
    while(true)
    {
    iSize=InData.read(Buffer);
    if(iSize==-1)
    {
    break;
    }
    outData.write(Buffer,0,iSize);
    }
    outData.flush();
    response.flushBuffer();
    }
    odbcRs.close();
    %>