Topic: jspSmart上传和下载的问题

  Print this page

1.jspSmart上传和下载的问题 Copy to clipboard
Posted by: kkk
Posted on: 2006-05-31 15:11

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,com.jspsmart.upload.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="mySmartupload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>上传文件</title>
</head>

<body>
<div align="center">
<p>文件上传
</p>
<hr>
<%
   int count=0;
   String destin="d:/tt";
   mySmartupload.initialize(pageContext);
   mySmartupload.upload();
   out.println(1);
String content=mySmartupload.getRequest().getParameter( "text1" );
   out.println(content);
   out.println(2);
   for(int i=0;i<mySmartupload.getFiles().getCount();i++)
   {
   out.println(3);
   com.jspsmart.upload.File myFile = mySmartupload.getFiles().getFileLight Bulb;
   if(!myFile.isMissing())
   {
    out.println(4);
     myFile.saveAs(destin+myFile.getFileName());
     out.println( " 文件名称"+myFile.getFieldName()+"<br>");
out.println( "文件大小 "+myFile.getSize()+"<br>");
out.println( "文件名称 "+myFile.getFileName()+"<br>");
out.println( "文件扩展名 "+myFile.getFileExt()+"<br>");
out.println( "文件大小 "+myFile.getFilePathName()+"<br>");
out.println( "文件路径 "+myFile.getFilePathName()+"<br>");
out.println( "文件类型 "+myFile.getContentType()+"<br>");
out.println( "contentdisp "+myFile.getContentDisp()+"<br>");
out.println( "MIME类型 "+myFile.getTypeMIME()+"<br>");

out.println( " </TABLE><BR> " );
      }
    }
%>
</div>
</body>
</html>
不知为什么,它实现不了上传功能,能不能帮忙看看呀???它是哪里出错了.

2.Re:jspSmart上传和下载的问题 [Re: kkk] Copy to clipboard
Posted by: chengbd
Posted on: 2006-06-02 02:42

也是在用这个组件,就帮你看看吧。以下的我对楼主的代码修改的结果,测试程序也是一项基本功,可要多花时间啊:)

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,com.jspsmart.upload.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="mySmartupload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>上传文件</title>
</head>

<body>
<div align="center">
<p>文件上传
</p>
<hr>
<%
int count=0;
String destin="d:/tt/";
mySmartupload.initialize(pageContext);
mySmartupload.upload();
out.println(1);
String content=mySmartupload.getRequest().getParameter( "text1" );
out.println(content);
out.println(2);
for(int i=0;i<mySmartupload.getFiles().getCount();i++)
{
out.println(3);
com.jspsmart.upload.File myFile = mySmartupload.getFiles().getFile(i);
if(!myFile.isMissing())
{
out.println(4);
myFile.saveAs(destin+myFile.getFileName());
out.println( " 文件名称"+myFile.getFieldName()+"<br>");
out.println( "文件大小 "+myFile.getSize()+"<br>");
out.println( "文件名称 "+myFile.getFileName()+"<br>");
out.println( "文件扩展名 "+myFile.getFileExt()+"<br>");
out.println( "文件大小 "+myFile.getFilePathName()+"<br>");
out.println( "文件路径 "+myFile.getFilePathName()+"<br>");
out.println( "文件类型 "+myFile.getContentType()+"<br>");
out.println( "contentdisp "+myFile.getContentDisp()+"<br>");
out.println( "MIME类型 "+myFile.getTypeMIME()+"<br>");
out.println( " </TABLE><BR> " );
}
}
%>
</div>
</body>
</html>

3.Re:jspSmart上传和下载的问题 [Re: kkk] Copy to clipboard
Posted by: chengbd
Posted on: 2006-06-02 02:44

你的: String destin="d:/tt";
我修改成了:String destin="d:/tt/";

运行测试成功。

4.Re:jspSmart上传和下载的问题 [Re: kkk] Copy to clipboard
Posted by: kkk
Posted on: 2006-06-22 15:07

我先谢谢你了呀.我那个错误我找到了.是前面有一个字母打错了,又不报错,才会这样.这个改不改都一样了.都能成功了.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923