获取form提交 form里面有个select,encType="multipart/form-data" POST提交,其中还有个file在里面,主要是要上传图片,select里面是要上传到的文件夹的ID,如何获取这个值?使用smartUpload上传的,图片上传正常,就是不能得到那个select的值,写数据库没法写进去 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 smartUpload没用过,不过好像smartUpload重写了request方法,我一直用commonfileuplaod SmartUpload mySmartUpload = new SmartUpload();String other=mySmartUpload.getRequest().getParameter("other"); //other为你的select的id 我以前做过,把代码贴出来共享:具体如下:提交: function uploadcrl(){ if(form1.files.value==""){ alert("请选择要上传的CRL文件"); return false; } form1.encoding = "MULTIPART/FORM-DATA"; form1.action="./uploadCRLAction.do"; form1.submit(); }后台处理: UploadCRLForm form = (UploadCRLForm) actionForm; FormFile file = form.getFiles(); String filepath = System.getProperty("user.dir") + "/" + "TEMPCRL.crl"; ShowCRLForm crlForm = new ShowCRLForm(); String crlFileContentType = file.getContentType(); try { InputStream stream = file.getInputStream();//把文件读入 OutputStream bos = new FileOutputStream(filepath ); //建立一个上传文件的输出流,将上传文件存入web应用的根目录。 //System.out.println(filePath+"/"+file.getFileName()); int bytesRead = 0; byte[] buffer = new byte[8192]; while ( (bytesRead = stream.read(buffer, 0, 8192)) != -1) { bos.write(buffer, 0, bytesRead);//将文件写入服务器 } bos.close(); stream.close(); }catch(Exception e){ e.printStackTrace(); } LZ用的什么框架上传的encType="multipart/form-data" 必须去判断是FILE还是STRING类型的表单,做不同的处理. 这个可以用,不过在upload();方法后才行 看看这个使用jspsmartupload解决enctype引起的无法同时上传文件和接值的问题 div 显示隐藏 点击提交操作时去掉隐藏的div里面的验证 jsp如何动态生成伪静态网页 用hibernate实现组合查询 请前辈们给点建议,并提供代表性书籍,谢谢! 有没有jsp建网站群,适合初学者的? JSP显示服务器地址的问题 版主``无意中发现转分贴```进来抓人啊 哪里有JBuilderX教材下载? 类型转换,INT 转变为 STRING,在线等待,解决马上给分。 请问要得到远程访问站点的ip地址以及所在的页面,用request的什么方法? JSP网页中下拉列表的问题 tomcat url处理问题
我一直用commonfileuplaod
String other=mySmartUpload.getRequest().getParameter("other"); //other为你的select的id
具体如下:提交:
function uploadcrl(){
if(form1.files.value==""){
alert("请选择要上传的CRL文件");
return false;
}
form1.encoding = "MULTIPART/FORM-DATA";
form1.action="./uploadCRLAction.do";
form1.submit();
}
后台处理:
UploadCRLForm form = (UploadCRLForm) actionForm;
FormFile file = form.getFiles();
String filepath = System.getProperty("user.dir") + "/" + "TEMPCRL.crl";
ShowCRLForm crlForm = new ShowCRLForm();
String crlFileContentType = file.getContentType();
try {
InputStream stream = file.getInputStream();//把文件读入
OutputStream bos = new FileOutputStream(filepath );
//建立一个上传文件的输出流,将上传文件存入web应用的根目录。
//System.out.println(filePath+"/"+file.getFileName());
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ( (bytesRead = stream.read(buffer, 0, 8192)) != -1) {
bos.write(buffer, 0, bytesRead);//将文件写入服务器
}
bos.close();
stream.close();
}catch(Exception e){
e.printStackTrace();
}
encType="multipart/form-data" 必须去判断是FILE还是STRING类型的表单,做不同的处理.
使用jspsmartupload解决enctype引起的无法同时上传文件和接值的问题