文件上传Upload

来源:互联网 发布:新浪短网址api js 编辑:程序博客网 时间:2024/05/17 08:10
<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()
0 0