protected void Page_Load(object sender, EventArgs e)
        {
            Response.Clear();
            var result = new FileUploadResult();
            if (Request.Files.Count > 0 && !string.IsNullOrEmpty(Request["hfUserID"]))
            {
                try
                {
                    //string uploadedUserName;
                    var content = new byte[Request.Files[0].ContentLength];

                    if (content.Length > MaxUploadSize && MaxUploadSize > 0)
                    {
                        result.ErrorText = WikiUCResource.wikiErrorFileSizeLimitText;
                    }
                    else
                    {
                        Request.Files[0].InputStream.Read(content, 0, Request.Files[0].ContentLength);
                        string localPath;
                        result.WebPath = TempFileContentSave(content, out localPath);
                        result.LocalPath = localPath;
                    }


                    Response.StatusCode = 200;
                    Response.Write(AjaxPro.JavaScriptSerializer.Serialize(result));
                }
                catch (Exception)
                {
                }
            }
            Response.End();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Clear();
            var result = new FileUploadResult();

            if (Request.Files.Count > 0 && !string.IsNullOrEmpty(Request["hfUserID"]))
            {
                try
                {
                    var file      = Request.Files[0];
                    var content   = new byte[file.ContentLength];
                    var fileExt   = Path.GetExtension(file.FileName);
                    var localPath = Guid.NewGuid() + fileExt;

                    if (content.Length > MaxUploadSize && MaxUploadSize > 0)
                    {
                        result.ErrorText = WikiUCResource.wikiErrorFileSizeLimitText;
                    }
                    else
                    {
                        file.InputStream.Read(content, 0, file.ContentLength);
                        result.WebPath   = TempFileContentSave(content, localPath);
                        result.LocalPath = localPath;
                    }

                    Response.StatusCode = 200;
                    Response.Write(AjaxPro.JavaScriptSerializer.Serialize(result));
                }
                catch (Exception)
                {
                }
            }
            Response.End();
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Clear();
            FileUploadResult result = new FileUploadResult();

            if (Request.Files.Count > 0 && !string.IsNullOrEmpty(Request["hfUserID"]))
            {
                try
                {
                    //string uploadedUserName;
                    byte[] content = new byte[Request.Files[0].ContentLength];

                    if (content.Length > MaxUploadSize && MaxUploadSize > 0)
                    {
                        result.ErrorText = WikiUCResource.wikiErrorFileSizeLimitText;
                    }
                    else
                    {
                        Request.Files[0].InputStream.Read(content, 0, Request.Files[0].ContentLength);
                        string localPath;
                        result.WebPath   = TempFileContentSave(content, out localPath);
                        result.LocalPath = localPath;
                    }


                    Response.StatusCode = 200;
                    Response.Write(AjaxPro.JavaScriptSerializer.Serialize(result));
                }
                catch (System.Exception) {}
            }
            Response.End();
        }