Example #1
0
    private void GetSize()
    {
        HttpFileCollection MyFileCollection;
        HttpPostedFile     MyFile;
        long   FileLen = 0;
        Stream MyStream;

        MyFileCollection = Request.Files;
        FileLen          = Request.InputStream.Length;

        if (FileLen > 0)
        {
            byte[] input = new byte[FileLen];
            MyStream          = Request.InputStream;
            MyStream.Position = 0;
            MyStream.Read(input, 0, (int)FileLen);
            FileStream fs         = null;
            string     token      = Request.Params["token"];
            string     name       = Request.Params["name"];
            string[]   names      = name.Split((".").ToCharArray());
            string     uploadPath = HttpContext.Current.Server.MapPath("UploadImages" + "\\") + token + "." + names[names.Length - 1];
            fs = new FileStream(uploadPath, FileMode.OpenOrCreate, FileAccess.Write);
            fs.Seek(0, SeekOrigin.End);
            fs.Write(input, 0, (int)FileLen);
            fs.Position = 0;
            FileLen     = fs.Length;
            MyStream.Dispose();
            MyStream.Close();
            fs.Dispose();
            fs.Close();
        }
        string value = "{start:" + FileLen + ",success:'true'}";

        Response.Clear();
        Response.Write(value);
        Response.End();        //*/
    }