获取form提交

tygfr2008 2008-11-27 06:06:21
form里面有个select,encType="multipart/form-data" POST提交,其中还有个file在里面,主要是要上传图片,select里面是要上传到的文件夹的ID,如何获取这个值?
使用smartUpload上传的,图片上传正常,就是不能得到那个select的值,写数据库没法写进去
...全文
492 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
steryzone 2008-11-29
  • 打赏
  • 举报
回复
如果是id的话试下转换成你要的类型再获取试试
tygfr2008 2008-11-29
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 haohao824 的回复:]
SmartUpload mySmartUpload = new SmartUpload();
String other=mySmartUpload.getRequest().getParameter("other"); //other为你的select的id
[/Quote]
这个可以用,不过在upload();方法后才行
zxcyfz 2008-11-28
  • 打赏
  • 举报
回复
LZ用的什么框架上传的
encType="multipart/form-data" 必须去判断是FILE还是STRING类型的表单,做不同的处理.
秋9 2008-11-27
  • 打赏
  • 举报
回复
我以前做过,把代码贴出来共享:
具体如下:

提交:
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();
}
haohao824 2008-11-27
  • 打赏
  • 举报
回复
SmartUpload mySmartUpload = new SmartUpload();
String other=mySmartUpload.getRequest().getParameter("other"); //other为你的select的id
liang__ 2008-11-27
  • 打赏
  • 举报
回复
smartUpload没用过,不过好像smartUpload重写了request方法,
我一直用commonfileuplaod
  • 打赏
  • 举报
回复
你把相关代码贴出来看看,
要是报错,把错误代码也贴出来
tygfr2008 2008-11-27
  • 打赏
  • 举报
回复
直接request.getParameter不行啊

81,091

社区成员

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

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