Exemplo n.º 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);
            }
Exemplo n.º 2
0
        public ActionResult UploadFile(FineUpload upload, string id)
        {
            // asp.net mvc will set extraParam1 and extraParam2 from the params object passed by Fine-Uploader
            //  return View();

            var dir      = Server.MapPath("~/UploadPictures/");
            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 }));
        }
Exemplo n.º 3
0
        public ActionResult UploadFile(FineUpload upload, int?id)
        {
            // asp.net mvc will set extraParam1 and extraParam2 from the params object passed by Fine-Uploader
            //  return View();
            PACKAGING pr = db.PACKAGINGs.Where(x => x.ID_PACKAGING == id).First();

            var dir      = Server.MapPath("~/UploadPictures/");
            var filePath = Path.Combine(dir, upload.Filename);

            pr.IMAGE           = "../../UploadPictures/" + upload.Filename;
            db.Entry(pr).State = EntityState.Modified;
            db.SaveChanges();
            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 = pr.IMAGE }));
        }