请问上传文件的问题

W_Brosnan 2005-07-31 03:02:09
页面里既有上传新闻图片又有新闻写数据库
都放在一个form里 ENCTYPE="multipart/form-data" 可以实现上传但是不能实现新闻写数据库
去掉ENCTYPE="multipart/form-data" 能实现新闻写数据库但是不能实现上传
有在一个form里实现上传图片和写数据库的方法吗?
...全文
249 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
maseccc 2005-08-04
  • 打赏
  • 举报
回复
jspsmartupload已发到你的邮箱, 请查收邮件。
W_Brosnan 2005-08-03
  • 打赏
  • 举报
回复
哪位用的很好大侠能提供一个jspsmartupload组件下载地址或发到我邮箱里w_brosnan@126.com谢谢!
darkzqt 2005-08-03
  • 打赏
  • 举报
回复
我 用的很好 就是有时候慢的很
W_Brosnan 2005-08-03
  • 打赏
  • 举报
回复
mySmartUpload.getRequest().getParameter("newsTitle");取的值还是NULL是不是组件或配置的问题
mysohu 2005-08-03
  • 打赏
  • 举报
回复
关注一下
bean5566 2005-08-03
  • 打赏
  • 举报
回复
mySmartUpload.getRequest().getParameter("parameterName");
bean5566 2005-08-03
  • 打赏
  • 举报
回复
可能是吧 我用就好好的!
liuruilrlr 2005-08-03
  • 打赏
  • 举报
回复
我用着也不好用,难道人品问题啊
liuruilrlr 2005-08-02
  • 打赏
  • 举报
回复
关注
ghostberry 2005-08-02
  • 打赏
  • 举报
回复
可以用struts阿

W_Brosnan 2005-08-02
  • 打赏
  • 举报
回复
我就是用的mySmartUpload.getRequest().getParameter("parameterName");呀!是不是SmartUpload有新版本了,还是别的什么问题?请知道的大侠指点!
弘石 2005-08-02
  • 打赏
  • 举报
回复
mySmartUpload.getRequest().getParameter("parameterName");就可以阿
shenpipi 2005-08-02
  • 打赏
  • 举报
回复
SmartUpload有时候就是不正常.
W_Brosnan 2005-08-02
  • 打赏
  • 举报
回复
好像还是不行!
maseccc 2005-08-01
  • 打赏
  • 举报
回复
String newsTitle=mySmartUpload.getRequest().getParameter("newsTitle");
if ((newsTitle==null) || (newsTitle.trim().equals("")))
{
newsTitle="";
}
out.println(newsTitle);
W_Brosnan 2005-07-31
  • 打赏
  • 举报
回复
if(mySmartUpload.getRequest().getParameter("newsTitle")==null||"".equals(mySmartUpload.getRequest().getParameter("newsTitle")))
newsTitle=null;
else
newsTitle=mySmartUpload.getRequest().getParameter("newsTitle");
out.println(newsTitle);
不管上一页面text 里newsTitle输入什么这边一直输出null还是得不到newsTitle的value啊!?
maseccc 2005-07-31
  • 打赏
  • 举报
回复
用jspsmartupload时获得表单中的文本的内容用:
String content = mySmartUpload.getRequest().getParameter("text1");
而不是request.getParameter("text1");
具体用法见下:(转帖)


JSP利用组件实现文件上传的全攻略
一、首先下载jspsmartupload组件


二、将目录jspsmartupload/wib_inf/classes中的内容拷贝到网站所在的实际目录中的WEB-INF中(resin是这个目录,其他的可能是classes,具体请查阅jspsmartupload/help/setup.htm)

三、如果是resin运行JSP,请在resin的conf/resin.conf中的
<web-app>和</web-app>中加入:
<path-mapping url-pattern=’/upload/*’ real-path=’f:\jsp\jspsmartupload\upload’/>

四、上传界面的代码如下:(文件名:insert.htm)
<FORM METHOD="POST" ACTION=" uploadfile.jsp" ENCTYPE="multipart/form-data">
<INPUT TYPE="FILE" NAME="FILE1" SIZE="50"><BR>
<INPUT TYPE="FILE" NAME="FILE2" SIZE="50"><BR>
<INPUT TYPE="FILE" NAME="FILE3" SIZE="50"><BR>
<INPUT TYPE="FILE" NAME="FILE4" SIZE="50"><BR>
主题:<input type="text" name="text1" ><br>
<INPUT type=submit value=写 完 name=ok>
</form>
注意上面的real-path目录

五、uploadfile.jsp的代码如下:
<%@page contentType="text/html;charset=gb2312"
language="java"
import="com.jspsmart.upload.*"%>
<jsp:useBean id="mySmartUpload"
scope="page"
class="com.jspsmart.upload.SmartUpload" />

<HTML>
<BODY >
<H1>文件上传JSP</H1>
<HR>
<%
int count=0;

//定义目标目录
String destination="/upload/";
mySmartUpload.initialize(pageContext);

//文件上传
mySmartUpload.upload();
//获得文本的内容
String content = mySmartUpload.getRequest().getParameter("text1");
//显示文本的内容
out.println(content);
//上传的情况统计
for (int i=0;i<mySmartUpload.getFiles().getCount();i++){
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(i);
if (!myFile.isMissing()){
myFile.saveAs(destination+ 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.getContentType() + "<BR>");
out.println("ContentDisp = " + myFile.getContentDisp() + "<BR>");
out.println("MIME类型 = " + myFile.getTypeMIME() + "<BR>");
out.println("SubTypeMIME = " + myFile.getSubTypeMIME() + "<BR>");
count ++;
}
}

out.println("<BR>可以上传" + mySmartUpload.getFiles().getCount() + "个文件<BR>");
out.println(count + "个文件已经被上传");
%>
</BODY>
</HTML>
以上就是JSP文件上传的全过程,Good Luck!
W_Brosnan 2005-07-31
  • 打赏
  • 举报
回复
jspsmart\upload
maseccc 2005-07-31
  • 打赏
  • 举报
回复
你用的是什么上传组件,或是自己写的上传程序?

81,114

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧