使用的是修改过的smartupload包,默认的jar包会出现上传后中文名乱码问题 <jsp:useBean id="smart" scope="page" class="com.jspsmart.upload.SmartUpload"/> <% request.setCharacterEncoding("gbk"); // 1、上传初始化 smart.initialize(pageContext) ; // 2、准备上传 smart.upload() ; // 3、保存上传的文件 smart.save("D:/upload") ; %> <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns="*" creationComplete="init();"> <mx:Script> <!--[CDATA[ import flash.net.FileReference; import mx.controls.Alert; import mx.events.CloseEvent; import flash.events.*; private var file: FileReference; private function init(): void{ Security.allowDomain("*"); file = new FileReference(); file.addEventListener(ProgressEvent.PROGRESS, onProgress); file.addEventListener(Event.SELECT, onSelect); file.addEventListener(Event.COMPLETE, completeHandle); } private function completeHandle(event:Event):void{ Alert.show("恭喜你,上传成功"); } private function upload(): void{ var imageTypes:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.png)", "*.jpg;*.jpeg;*.png"); var allTypes:Array = new Array(imageTypes); file.browse(allTypes); file.browse(); } private function onSelect(e: Event): void{ Alert.show("上传 " + file.name + " (共 "+Math.round(file.size)+" 字节)?", "确认上传", Alert.YES|Alert.NO, null, proceedWithUpload); } private function onProgress(e: ProgressEvent): void{ lbProgress.text = " 已上传 " + e.bytesLoaded + " 字节,共 " + e.bytesTotal + " 字节"; var proc: uint = e.bytesLoaded / e.bytesTotal * 100; bar.setProgress(proc, 100); bar.label= "当前进度: " + " " + proc + "%"; } private function proceedWithUpload(e: CloseEvent): void{ if (e.detail == Alert.YES){ var request: URLRequest = new URLRequest("http://localhost:8400/lcds/FileUpload.jsp"); try { file.upload(request); } catch (error:Error) { trace("上传失败"); } } } ]]--> </mx:Script> <mx:Canvas width="100%" height="100%" x="10" y="170" fontSize="15"> <mx:VBox width="100%" horizontalAlign="center"> <mx:Label id="lbProgress" text="上传"/> <mx:ProgressBar id="bar" labelPlacement="bottom" themeColor="#F20D7A" minimum="0" visible="true" maximum="100" label="当前进度: 0%" direction="right" mode="manual" width="200"/> <mx:Button label="上传文件" click="upload();"/> </mx:VBox> </mx:Canvas> </mx:Application> <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns="*" creationComplete="init();"> <mx:Script> <!--[CDATA[ import flash.net.FileReference; import mx.controls.Alert; import mx.events.CloseEvent; import flash.events.*; private var file: FileReference; private function init(): void{ Security.allowDomain("*"); file = new FileReference(); file.addEventListener(ProgressEvent.PROGRESS, onProgress); file.addEventListener(Event.SELECT, onSelect); file.addEventListener(Event.COMPLETE, completeHandle); } private function completeHandle(event:Event):void{ Alert.show("恭喜你,上传成功"); } private function upload(): void{ var imageTypes:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.png)", "*.jpg;*.jpeg;*.png"); var allTypes:Array = new Array(imageTypes); file.browse(allTypes); file.browse(); } private function onSelect(e: Event): void{ Alert.show("上传 " + file.name + " (共 "+Math.round(file.size)+" 字节)?"