public class IndexModel : PageModel { private Cls_NeedCode needCode = new Cls_NeedCode(); [BindProperty] public Register.Select Register { get; set; } private IHostingEnvironment _environment; public IndexModel(IHostingEnvironment environment) { _environment = environment; } [BindProperty, Display(Name = "فایل")] public IFormFile UploadedFile { get; set; } public async Task OnPostAsync() { string path = Path.Combine(_environment.ContentRootPath, "wwwroot/uploads/Profile/" + this.Register.R_National_Code_Or_Passports); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var file = Path.Combine(_environment.ContentRootPath, "wwwroot/uploads/Profile/" + this.Register.R_National_Code_Or_Passports, needCode.Generate_Unique_Number() + UploadedFile.FileName); using (var fileStream = new FileStream(file, FileMode.Create)) { await UploadedFile.CopyToAsync(fileStream); } } [BindProperty, Display(Name = "امضا")] public IFormFile UploadedFileSign { get; set; } public async Task OnPostSignAsync() { string path = Path.Combine(_environment.ContentRootPath, "wwwroot/uploads/Sign/" + this.Register.R_National_Code_Or_Passports); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var file = Path.Combine(_environment.ContentRootPath, "wwwroot/uploads/Sign/" + this.Register.R_National_Code_Or_Passports, needCode.Generate_Unique_Number() + UploadedFileSign.FileName); using (var fileStream = new FileStream(file, FileMode.Create)) { await UploadedFileSign.CopyToAsync(fileStream); } } public void OnGet() { } } |