Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult Tupload(){
- return View();
- }
- [HttpPost]
- [ValidateAntiForgeryToken]
- //public JsonResult DoUpload([FromForm] Object obj, [FromForm] IFormFile file) { <-- Model bound complex types must not be abstract or value types and must have a parameterless constructor.
- //public async Task<IActionResult> Post(List<IFormFile> files) <- files is always empty
- //public JsonResult DoUpload(IFormFile files) { <- Model bound complex types must not be abstract or value types and must have a parameterless constructor.
- //public JsonResult DoUpload(UploadedDocument files) { <- attachment attribute, which is IFormFile is null
- //public JsonResult DoUpload ( [FromBody] UploadedDocument files) { <- 415 Unsupported Media Type
- //public JsonResult DoUpload ( [FromForm] UploadedDocument files) { <- {"attachment":null}
- //public JsonResult DoUpload (UploadedDocument file, IFormFile doc) { <- Model bound complex types must not be abstract or value types and must have a parameterless constructor.
- //public JsonResult DoUpload (List<IFormFile> files ) { <- files is null
- //public JsonResult DoUpload (Object files) { <- returns {} when (attempting to return Json(files))
- public JsonResult DoUpload (List<IFormFile> files) {
- return Json(files.Count);
- //return Json(new { filename = files.Name, size = files.Length } );
- /*
- long size = files.Sum(f => f.Length);
- // full path to file in temp location
- var filePath = Path.GetTempF ileName();
- foreach (var formFile in files)
- {
- if (formFile.Length > 0)
- {
- using (var stream = new FileStream(filePath, FileMode.Create))
- {
- await formFile.CopyToAsync(stream);
- }
- }
- }
- // process uploaded files
- // Don't rely on or trust the FileName property without validation.
- return Json(new { count = files.Count, size, filePath});
- */
- //return Json(Request.Form);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement