利用layui框架可以上传文件调试拦截成功!
[HttpPost] public IActionResult Method1(IFormFile file) { return Json(new{success="ok"}); }
<div class="layui-card"> <div class="layui-card-header">拖拽上传</div> <div class="layui-card-body"> <div class="layui-upload-drag" id="test-upload-drag"> <i class="layui-icon layui-icon-upload"></i> <p>点击上传,或将文件拖拽到此处</p> </div><input class="layui-upload-file" type="file"> </div> </div> <script> layui.use("upload", function() { layui.upload.render({ elem: ‘#test-upload-drag‘, url: ‘@Url.Action("Method1")‘, accept:"file", done: function(res) { //上传完毕回调 }, error: function() { //请求异常回调 } }); }); </script>
原文地址:https://www.cnblogs.com/yzpopulation/p/9320632.html
时间: 2024-10-09 15:43:40