zoukankan      html  css  js  c++  java
  • Flex3上传附件至服务器

    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);
            }

        }

  • 相关阅读:
    Google Style Guides-Shell Style Guide
    支付宝钱包手势password破解实战(root过的手机可直接绕过手势password)
    学习Java JDBC,看这篇就够了
    php学习之道:WSDL具体解释(一)
    Android学习笔记(17):文本框TextView类
    HttpSession的深入分析与研究
    【leetcode】atoi (hard) ★
    【leetcode】Candy(hard) 自己做出来了 但别人的更好
    【leetcode】Substring with Concatenation of All Words (hard) ★
    【leetcode】 Search a 2D Matrix (easy)
  • 原文地址:https://www.cnblogs.com/threestone/p/1714794.html
Copyright © 2011-2022 走看看