form表单上传文件后,获取成功或者失败信息
jsp部分:
<form id="add_form" action="addPerson.action" method="post" enctype="multipart/form-data" namespace="/">
<div >
<table>
<tr>
<td> </td>
<td>
<div>
<input id="eduFileName" name="eduFileName" type="text" class="input03" readonly/>
<input id="eduFile" name="eduFile" type="file" style="width:0px" onchange="onUploadImgChange(this,'edu')">
<input id="getEduFile" name="getEduFile" type="button" value="选择文件" onclick="eduFile.click();"class="btn03"/>
<p class="pic—01"><div id="eduPreviewFake"><img id="eduPreview" onload="onPreviewLoad(this)"/></div>
</p>
</div></td>
</tr>
</table>
这是一个人员添加页面,大概有40多个字段,其中6个字段需要上传图片并预览,通过submit按钮触发action,将form表单提交到后台
Java部分:
public String addPerson() throws Exception {
Staff staff=new Staff();/
String eduPath=getPath(eduFile,eduFileName);
staff.setEduPath(eduPath);
return msg;
将文件上传后,存储路径。
现在的问题是,我无法将保存成功或者失败的信息返回到前台
使用ajax不可避免的会用到上传控件,而控件会破坏我页面的样式,也就是风格不统一
大家有什么好的办法没有?
<form id="add_form" action="addPerson.action" method="post" enctype="multipart/form-data" namespace="/">
<div >
<table>
<tr>
<td> </td>
<td>
<div>
<input id="eduFileName" name="eduFileName" type="text" class="input03" readonly/>
<input id="eduFile" name="eduFile" type="file" style="width:0px" onchange="onUploadImgChange(this,'edu')">
<input id="getEduFile" name="getEduFile" type="button" value="选择文件" onclick="eduFile.click();"class="btn03"/>
<p class="pic—01"><div id="eduPreviewFake"><img id="eduPreview" onload="onPreviewLoad(this)"/></div>
</p>
</div></td>
</tr>
</table>
这是一个人员添加页面,大概有40多个字段,其中6个字段需要上传图片并预览,通过submit按钮触发action,将form表单提交到后台
Java部分:
public String addPerson() throws Exception {
Staff staff=new Staff();/
String eduPath=getPath(eduFile,eduFileName);
staff.setEduPath(eduPath);
return msg;
将文件上传后,存储路径。
现在的问题是,我无法将保存成功或者失败的信息返回到前台
使用ajax不可避免的会用到上传控件,而控件会破坏我页面的样式,也就是风格不统一
大家有什么好的办法没有?
...全文
相关推荐
excle文件form表单上传
jsp from表单上传页面,servlet java接收页面附件与页面其他信息,保存附件到服务器,保存附件与其他信息到数据库(紧jsp与Java代码)
使用VBScript类上传文件
使用VBScript类上传文件。 当您无法部署自定义COM对象时很有用。
Struts实现图片上传添加水印和压缩
实现技术:Struts1.3+JSP 主要实现:上传文件类型的前台验证,后台验证上传文件的类型、格式;实现图片的压缩和添加水印等功能。
在一个form表单里同时上传多个文件和文本信息的解决方案
在一个form表单里同时上传多个文件和文本信息的解决方案
不用form提交表单,用ajax上传文件
不用form提交表单,用ajax异步上传文件,使用jdk8版本,否则可能无法运行


