多文件上传[Flash]
重新修改了以前的多文件上传,加入了JPG图片压缩功能!
概述 Flash多文件上传,提供JPG图片压缩选项。显示文件上传进度!
Flash参数说明
:)
说明:
当imageWidth和imageHeight都为0时,不对JPG图片进行任何缩放,将直接上传原始图片! 当imageWidth或imageHeight任意一个值不为0时,则对JPG图片进行缩放操作。 上传时文本提示默认为:{%} {uploadSize}/{allSize} {fileSize} {fileName} {%} 表示当前上传百分比 {uploadSize} 已上传的总文件大小 {allSize} 需要上传的总文件大小 {fileIndex} 当前正上传第几个文件 {fileCount} 文件总数 {fileSize} 当前上传的文件大小 {fileName} 当前上传的文件名称 Flash提供的接口函数
setPara 设置上传参数。setPara(参数标识,值)
返回值:true设置成功。false设置失败!当上传时不允许设置。
isBusy 返回当前Flash是否正在上传。返回值:true正在上传。false空闲。
JS函数接口 参数:type, str type 类型 str 信息
type类型 str值 说明

注意:因为可上传的文件扩展名可通过JS修改,所以需要在服务器端后台验证文件扩展名是否正确!
实例及源码下载:http://files.cnblogs.com/zjfree/mFileUpload.rar
后记:
2011-12-20 上传一个小图片,后上传一个大图片,大图片就不压缩问题,已经修复。欢迎提出问题!
2011-12-21 在批量上传时,不会触发upload_complete过程。脚本无法判断是否上传完成。 问题已修复。
解决了,不能用 DiskFileItemFactory factory = new DiskFileItemFactory(); 或者是 FileItem读取。
我换成这这种读法: ServletInputStream in = request.getInputStream(); StringBuffer sb = new StringBuffer(); FileOutputStream ou = new FileOutputStream("d:\testupload\"+System.currentTimeMillis()+".jpg"); byte b = new byte; int len = 0; while((len = in.read(b))!=-1){ ou.write(b, 0, len); } in.close(); ou.close();
var params = { serverUrl: "/vssj/fileUploadAction.do?method=upload", jsFunction: "flashReturn", imageWidth:100 } 去掉imageWidth就可以上传。 加上imageWidth就报:the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is applicatoin/octet-stream
我改了mFileUpload.mxml,重新编译报Error#2176
我用的java,上传提示: the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is applicatoin/octet-stream。 有编译成multipart/form-data的版本吗?