public FileStatusCode UploadFile([FromForm] IFormCollection collection)
        {
            FileStatusCode result      = new FileStatusCode();
            var            imgpath     = collection["imgpath"].ToString();
            var            files       = collection.Files;
            var            fname       = "";
            var            path        = "";
            string         newFileName = string.Empty;

            try
            {
                foreach (var file in files)
                {
                    if (file.Length <= 0)
                    {
                        continue;
                    }

                    if (!Directory.Exists(basepath))
                    {
                        Directory.CreateDirectory(basepath);
                    }

                    fname = file.FileName;
                    string type = fname.Substring(fname.LastIndexOf(".") + 1);
                    if (fname != "")
                    {
                        newFileName = Guid.NewGuid().ToString().Replace("-", "") + "." + type;
                    }


                    path = Path.Combine(basepath, imgpath + newFileName);


                    using (FileStream fs = new FileStream(path, FileMode.Create))
                    {
                        file.CopyTo(fs);
                        //retvalue++;
                    }
                }

                result.Status  = "200";
                result.Message = $"图片 {fname} 上传成功";
                result.ImgUrl  = ImgConfig.img_url + newFileName;
            }
            catch (Exception ex)
            {
                result.Status  = "400";
                result.Message = ex.Message;
            }

            return(result);
        }
 public Builder SetStatusCode(FileStatusCode statusCode)
 {
     this.statusCode = statusCode;
     return(this);
 }