Azure Lei Zhang的博客

weibo: LeiZhang的微博/QQ: 185165016/QQ群:319036205/邮箱:leizhang1984@outlook.com/TeL:139-161-22926

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

private var file:FileReference;

private var displayTypes:FileFilter=new FileFilter("Excel文件(*.xls)","*.xls");
private var fileFilter:Array=new Array(displayTypes);

//初始化

file = new FileReference();
file.addEventListener(Event.SELECT, onSelect);
file.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,xmlComplete);

//浏览本地文件

file.browse(fileFilter);

 private function onSelect(e: Event): void
{
            Alert.show("上传 " + file.name + " (共 "+Math.round(file.size)+" 字节)?",
                            "确认上传",Alert.YES|Alert.NO,null,proceedWithUpload);                        

}

 private function proceedWithUpload(e:CloseEvent): void
 {
             if (e.detail == Alert.YES)
             {
              var upLoadUrl:String=spExcelUrl;
                var request:URLRequest = new URLRequest(upLoadUrl);
                CursorManager.setBusyCursor();
                file.upload(request);
               
                //loading
               swfLoader.source="assets/2/loading.swf";
               swfLoader.alpha=0.8;
               swfLoader.isPopUp=true;
               mx.managers.PopUpManager.addPopUp(swfLoader, DisplayObject(parentApplication), true);
               mx.managers.PopUpManager.centerPopUp(swfLoader); 
             }
 }

 

    //c#

    string uploadFolder = "upload"; // 上传文件夹
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpFileCollection files = Request.Files;

        if (files.Count == 0)
        {
            Response.Write("请勿直接访问本文件");
            Response.End();
        }

        string path = Server.MapPath(uploadFolder);

        // 只取第 1 个文件
        HttpPostedFile file = files[0];

        if (file != null && file.ContentLength > 0)
        {
            // flash 会自动发送文件名到 Request.Form["fileName"]
            string savePath = path + "/" + Request.Form["fileName"];
            file.SaveAs(savePath);
            getXml(savePath);
            System.IO.File.Delete(savePath);
        }

    }

posted on 2010-04-18 16:49  Lei Zhang的博客  阅读(1010)  评论(0编辑  收藏  举报