<form action="xx.jsp" method="post" enctype="multipart/form-data">
照片:<input type="file">
</form>
得大上传的输入流:
public ServletInputStream getInputStream() throws IOException;
SmartUplodd组件,进行文件上传步骤
·实例化SmartUpload类对象: SmartUpload smart = new SmartUpload();
·初始化上传的操作: smart.initialize(config,request,response);
·接受所有的上传文件数据 smart.upliad();
·进行数据的保存 smart.save("/upload");
通过文件上传之后,就不可以依靠request的方法来获取对象了,要通过
Smartupload中的方法处理
·接收单个参数:smart.getRequest().getParameter(String name);
·接收一组参数:smart.getRequest().getParameterValues(String name);
·接收全部参数名称:smart.getRequest().getParameterNames();
·判断是否由文件上传,如果有,长度一定大于0
文件大小:smart.getFiles().getSize()
·判断文件上传的数量,
文件数量:smart.getFiles.getCount();
·或得文件名称:smart.getFiles().getFile(i).getFileName()
·或得文件后缀:smart.getFiles().getFile(i).getFileExt()
·或得文件类型:smart.getFiles().getFile(i).getContentType()
SmartUpload基础
最新推荐文章于 2021-01-02 11:07:29 发布