带页面返回值处理的
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx"
    creationComplete="init()" xmlns:local="*">
 
 <fx:Script>
  <![CDATA[
   
  private const defaultRequestUrl : String = "http://192.168.0.212:8002/Talk/UploadHandler.ashx";
  
  private var file : FileReference;
  
  private function init():void {
   Security.allowDomain("*");
   
   file = new FileReference();
   file.addEventListener(Event.SELECT, onFileSelect);
   file.addEventListener(ProgressEvent.PROGRESS, progressHandle);
   file.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, completeHandle);
   //file.addEventListener(Event.OPEN, openHandle);
   //file.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
   //file.addEventListener(Event.CANCEL, cancelHandler);
  }
  
  private function onClickBrowserBtn() : void {
   file.browse(getTypeFilter());
  }
  
  private function getTypeFilter() : Array {
   var imagesFilter:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg;*.jpeg;*.gif;*.png");
   //var docFilter:FileFilter = new FileFilter("Documents", "*.pdf;*.doc;*.txt");
   
   return [imagesFilter];
  }
  
  private function onFileSelect(event : Event) : void {
   uploadBtn.enabled = true;
   infoText.htmlText = 
     "Name: " + file.name + "<br/>" + 
     "Size: " + file.size + "<br/>" + 
     "Type: " + file.type + "<br/>" + 
     "Date: " + file.creationDate;
  }
  
  private function onClickUploadBtn() : void {
   var request : URLRequest = new URLRequest(defaultRequestUrl);
   request.data = "userId=123";
   file.upload(request);
  }
  
  private function progressHandle(event : ProgressEvent) : void {
   progressLabel.text = "complete " + event.bytesLoaded + " bytes";
   var fileUploadPercent : uint = event.bytesLoaded / event.bytesTotal * 100;
   uploadProgressBar.setProgress(fileUploadPercent, 100);
   uploadProgressBar.label = "Complete " + fileUploadPercent + "%";
  }
  
  private function completeHandle(event : DataEvent) : void {
   infoText.htmlText = "Upload " + file.name + " Complete!<br>"+event.data;
   uploadBtn.enabled = false;
  }
   
  ]]>
 </fx:Script>
 
 <mx:Button id="browserBtn" x="10" y="69" label="Browser" 
      click="onClickBrowserBtn()"/>
 
 <mx:Button id="uploadBtn" x="236" y="69" label="Upload" enabled="false" 
      click="onClickUploadBtn()"/>
 
 <mx:ProgressBar id="uploadProgressBar" x="10" y="33" width="291" 
     maximum="100" direction="right" mode="manual"/>
 
 <mx:TextArea id="infoText" x="10" y="99" width="291" height="131"/>
 <mx:Label id="progressLabel" x="10" y="10" width="291"/>
</s:Application>
示例1:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx" xmlns="*" creationComplete="init();">   
 <fx: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);   
  }   
  
  private function upload(): void{   
   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://192.168.0.212:8002/Talk/UploadHandler.ashx");   
    try {   
     file.upload(request);   
    } catch (error:Error) {   
     trace("上传失败");   
    }   
    
   }   
  }   
   ]]>   
  </fx:Script>   
     
  <mx:Canvas width="100%" height="100%">   
   <mx:VBox width="100%" horizontalAlign="center">   
    <mx:Label id="lbProgress" text="上传"/>   
    <mx:ProgressBar id="bar" labelPlacement="bottom"
        minimum="0" visible="true" maximum="100" label="当前进度: 0%"      
        direction="right" mode="manual" width="200"/>   
    <mx:Button label="上传文件" click="upload();"/>                
   </mx:VBox>   
  </mx:Canvas>   
</s:Application>   
示例2:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx"
    creationComplete="init()">
 
 <fx:Script>
  <![CDATA[
   
   private const defaultRequestUrl : String = "http://192.168.0.212:8002/Talk/UploadHandler.ashx";
   
   private var file : FileReference;
  
  private function init():void {
   Security.allowDomain("*");
   
   file = new FileReference();
   file.addEventListener(Event.SELECT, onFileSelect);
   file.addEventListener(ProgressEvent.PROGRESS, progressHandle);
   file.addEventListener(Event.COMPLETE, completeHandle);
   //file.addEventListener(Event.OPEN, openHandle);
   //file.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
   //file.addEventListener(Event.CANCEL, cancelHandler);
  }
  
  private function onClickBrowserBtn() : void {
   file.browse(getTypeFilter());
  }
  
  private function getTypeFilter() : Array {
   var imagesFilter:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg;*.jpeg;*.gif;*.png");
   //var docFilter:FileFilter = new FileFilter("Documents", "*.pdf;*.doc;*.txt");
   
   return [imagesFilter];
  }
  
  private function onFileSelect(event : Event) : void {
   uploadBtn.enabled = true;
   infoText.htmlText = 
     "Name: " + file.name + "<br/>" + 
     "Size: " + file.size + "<br/>" + 
     "Type: " + file.type + "<br/>" + 
     "Date: " + file.creationDate;
  }
  
  private function onClickUploadBtn() : void {
   var request : URLRequest = new URLRequest(defaultRequestUrl);
   request.data = "userId=123";
   file.upload(request);
  }
  
  private function progressHandle(event : ProgressEvent) : void {
   progressLabel.text = "complete " + event.bytesLoaded + " bytes";
   var fileUploadPercent : uint = event.bytesLoaded / event.bytesTotal * 100;
   uploadProgressBar.setProgress(fileUploadPercent, 100);
   uploadProgressBar.label = "Complete " + fileUploadPercent + "%";
  }
  
  private function completeHandle(event : Event) : void {
   infoText.htmlText = "Upload " + file.name + " Complete!";
   uploadBtn.enabled = false;
  }
  ]]>
 </fx:Script>
 
 <mx:Button id="browserBtn" x="10" y="69" label="Browser" 
      click="onClickBrowserBtn()"/>
 
 <mx:Button id="uploadBtn" x="236" y="69" label="Upload" enabled="false" 
      click="onClickUploadBtn()"/>
 
 <mx:ProgressBar id="uploadProgressBar" x="10" y="33" width="291" 
     maximum="100" direction="right" mode="manual"/>
 
 <mx:TextArea id="infoText" x="10" y="99" width="291" height="131"/>
 <mx:Label id="progressLabel" x="10" y="10" width="291"/>
 
</s:Application>
.net后台
/// <summary>
    /// UploadHandler 的摘要说明
    /// </summary>
    public class UploadHandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset = "utf-8";
HttpPostedFile file = context.Request.Files["Filedata"];
            if (file != null)
            {
                string newFilePath = context.Server.MapPath("~/") + "/files/" + DateTime.Now.ToString("yyyy") + "\\" + DateTime.Now.ToString("MM") + "\\" + DateTime.Now.ToString("dd") + "\\";
                Directory.CreateDirectory(newFilePath);
                string newFileName = DateTime.Now.Ticks.ToString() + file.FileName.Substring(file.FileName.LastIndexOf('.'));
                file.SaveAs(newFilePath + newFileName);
                string url = "/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/" + newFileName;
                //context.Session["MovieFile"] = new PFileInfo(file.FileName, file.ContentLength, url, file.FileName.Substring(file.FileName.LastIndexOf('.')));
                context.Response.Write(url);
            }
            else
            {
                context.Response.Write("");
            }
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }