enctype="multipart/form-data" php,form表单中enctype="multipart/form-data"问题????

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

哟 SmartUpLoad 中国人写的上传下载的一个模板。

SmartUpload smartUpload=new SmartUpload();

//Common

//paraseRequest();

ServletConfig config=this.getServletConfig();

smartUpload.initialize(config, request, response);

try {

smartUpload.upload();//parseRquest(request);

} catch (SmartUploadException e) {

e.printStackTrace();

//HttpServletRequest不是一个东西

//SmartUpload自己封装的

//内部维护了一个hashmap

//简单控件中的值都封装在了hashmap中

Request req=smartUpload.getRequest();

String proName=req.getParameter("proName");

String strProPrice=req.getParameter("proPrice");

double proPrice=new Double(strProPrice);

String proDis=req.getParameter("proDis");

//文件

Files fs=smartUpload.getFiles();

int size=fs.getCount();

String imageUrl="";

for (int i = 0; i < size; i++) {

File f=fs.getFile(i);

String fieldName=f.getFieldName();//控件名字

String pathName=f.getFilePathName();//文件名字

//c:/hello/hello.gif

//此处需要处理,有可能得到的是一个文件的路径....

System.out.println(fieldName+" ---- "+pathName);

imageUrl+="img/"+pathName+",";

String realPath=request.getRealPath("/img/"+pathName);

System.out.println(realPath);

try {

f.saveAs(realPath);//把文件保存在服务器磁盘上.....

} catch (SmartUploadException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

imageUrl=imageUrl.substring(0,imageUrl.length()-1);

System.out.println(imageUrl);//真是路径

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值