示例#1
0
            public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
            {
                var request    = controllerContext.RequestContext.HttpContext.Request;
                var formUpload = request.Files.Count > 0;

                // find filename
                var xFileName    = request.Headers["X-File-Name"];
                var qqFile       = request["qqfile"];
                var formFilename = formUpload ? request.Files[0].FileName : null;

                var upload = new FineUpload
                {
                    Filename    = xFileName ?? qqFile ?? formFilename,
                    InputStream = formUpload ? request.Files[0].InputStream : request.InputStream
                };

                return(upload);
            }
示例#2
0
        //[HttpPost]
        public FineUploaderResult UploadFile(FineUpload upload, string extraParam1)
        {
            // asp.net mvc will set extraParam1 and extraParam2 from the params object passed by Fine-Uploader

            var dir      = @"c:\upload\path";
            var filePath = Path.Combine(dir, upload.Filename);

            try
            {
                upload.SaveAs(filePath);
            }
            catch (Exception ex)
            {
                return(new FineUploaderResult(false, error: ex.Message));
            }

            // the anonymous object in the result below will be convert to json and set back to the browser
            return(new FineUploaderResult(true, new { extraInformation = 12345 }));
        }