newxy1.02文件上传到文件夹、到数据库的方法如下:1.上传文件到服务器文件夹中的方法:
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/WEB-INF/newxy-html.tld" prefix="nhtml"%>
<%@ taglib uri="/WEB-INF/newxy-logic.tld" prefix="nlogic"%><nlogic:action1 id="act1" formName="fileForm"/>
<nhtml:form action="" formName="fileForm" enctype="multipart/form-data">
文件夹:<input type="text" name="_directory" size="40"/><br />
文件1,不大于1024K:<nhtml:file property="file1" size="40" maxSize="1024"/><br />
文件2,不大于1024K:<nhtml:file property="file2" size="40" maxSize="1024"/><br />
</nhtml:form>
<nhtml:button actionId="act1" method="upload"/>2.上传文件到数据库中的方法:
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/WEB-INF/newxy-html.tld" prefix="nhtml"%>
<%@ taglib uri="/WEB-INF/newxy-logic.tld" prefix="nlogic"%><nlogic:action1 id="act1" formName="fileForm"/>
<nhtml:form action="" formName="fileForm" enctype="multipart/form-data">
数据库表名:<input type="text" name="_table" size="40"/><br />
说明:<input type="text" name="explain" size="40"/><br />
文件1,不大于1024K:<nhtml:file property="file1" size="40" maxSize="1024"/><br />
文件2,不大于1024K:<nhtml:file property="file2" size="40" maxSize="1024"/><br />
</nhtml:form>
<nhtml:button actionId="act1" method="update"/>这两种方法是不是最简单的,而且很相似。大家帮忙比较,找到更简单的方法送50分。
newxy技术网站:http://www.newxy.net
有关文件上传:
文件上传至文件夹: http://www.newxy.net/doc.jsp#anchor15.1
文件上传至数据库: http://www.newxy.net/doc.jsp#anchor15.2
文件上传至文件夹与上传至数据库的比较:http://www.newxy.net/doc.jsp#anchor15.3
有关范例:
http://www.newxy.net/zh_cn/samples/sample2/demo.jsp
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/WEB-INF/newxy-html.tld" prefix="nhtml"%>
<%@ taglib uri="/WEB-INF/newxy-logic.tld" prefix="nlogic"%><nlogic:action1 id="act1" formName="fileForm"/>
<nhtml:form action="" formName="fileForm" enctype="multipart/form-data">
文件夹:<input type="text" name="_directory" size="40"/><br />
文件1,不大于1024K:<nhtml:file property="file1" size="40" maxSize="1024"/><br />
文件2,不大于1024K:<nhtml:file property="file2" size="40" maxSize="1024"/><br />
</nhtml:form>
<nhtml:button actionId="act1" method="upload"/>2.上传文件到数据库中的方法:
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/WEB-INF/newxy-html.tld" prefix="nhtml"%>
<%@ taglib uri="/WEB-INF/newxy-logic.tld" prefix="nlogic"%><nlogic:action1 id="act1" formName="fileForm"/>
<nhtml:form action="" formName="fileForm" enctype="multipart/form-data">
数据库表名:<input type="text" name="_table" size="40"/><br />
说明:<input type="text" name="explain" size="40"/><br />
文件1,不大于1024K:<nhtml:file property="file1" size="40" maxSize="1024"/><br />
文件2,不大于1024K:<nhtml:file property="file2" size="40" maxSize="1024"/><br />
</nhtml:form>
<nhtml:button actionId="act1" method="update"/>这两种方法是不是最简单的,而且很相似。大家帮忙比较,找到更简单的方法送50分。
newxy技术网站:http://www.newxy.net
有关文件上传:
文件上传至文件夹: http://www.newxy.net/doc.jsp#anchor15.1
文件上传至数据库: http://www.newxy.net/doc.jsp#anchor15.2
文件上传至文件夹与上传至数据库的比较:http://www.newxy.net/doc.jsp#anchor15.3
有关范例:
http://www.newxy.net/zh_cn/samples/sample2/demo.jsp
2.解压,将newxy1.02.jar拷到WEB-INF/lib下,将newxy-html.tld,newxy-logic.tld,newxy-bean.tld三个标签定义文件拷到WEB-INF/classes下.
3.复制下面代码到你的jsp文件中,就可以上传文件到服务器文件夹中了。<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/WEB-INF/newxy-html.tld" prefix="nhtml"%>
<%@ taglib uri="/WEB-INF/newxy-logic.tld" prefix="nlogic"%><nlogic:action1 id="act1" formName="fileForm"/>
<nhtml:form action="" formName="fileForm" enctype="multipart/form-data">
文件夹:<input type="text" name="_directory" size="40"/><br />
文件1,不大于1024K:<nhtml:file property="file1" size="40" maxSize="1024"/><br />
文件2,不大于1024K:<nhtml:file property="file2" size="40" maxSize="1024"/><br />
</nhtml:form>
<nhtml:button actionId="act1" method="upload"/>
你可以限制上传文件类型,参见:http://www.newxy.net/doc.jsp#anchor13.3.9如果你做好了获取数据库连接的准备,将下列代码拷到jsp文件中,就可以上传文件到数据库中了。
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/WEB-INF/newxy-html.tld" prefix="nhtml"%>
<%@ taglib uri="/WEB-INF/newxy-logic.tld" prefix="nlogic"%><nlogic:action1 id="act1" formName="fileForm"/>
<nhtml:form action="" formName="fileForm" enctype="multipart/form-data">
数据库表名:<input type="text" name="_table" size="40"/><br />
说明:<input type="text" name="explain" size="40"/><br />
文件1,不大于1024K:<nhtml:file property="file1" size="40" maxSize="1024"/><br />
文件2,不大于1024K:<nhtml:file property="file2" size="40" maxSize="1024"/><br />
</nhtml:form>
<nhtml:button actionId="act1" method="update"/>获取数据连接的方法可参见 《文件上传至数据库》: http://www.newxy.net/doc.jsp#anchor15.2
利用struts之类的优秀工具,使开发效率达到最化。