Here are the examples of the csharp api System.Collections.Generic.List.Add(imageEdit) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
19
View Source File : FileController.cs
License : Apache License 2.0
Project Creator : ccnetcore
License : Apache License 2.0
Project Creator : ccnetcore
[HttpPost]
[Obsolete]
public async Task<IActionResult> OnPostUploadImage([FromServices] IHostingEnvironment environment)
{
List<imageEdit> fileUrl = new List<imageEdit>();
var files = Request.Form.Files;
if (string.IsNullOrWhiteSpace(environment.WebRootPath))
{
environment.WebRootPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot");
}
string webRootPath = environment.WebRootPath;
string filePath = Path.Combine(webRootPath + "/upload/images");
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
foreach (var formFile in files)
{
if (formFile.Length > 0)
{
var ext = Path.GetExtension(formFile.FileName);
var fileName = Guid.NewGuid().ToString() + ext;
var path = Path.Combine(webRootPath + "/upload/images", fileName);
using (var stream = new FileStream(path, FileMode.CreateNew))
{
await formFile.CopyToAsync(stream);
fileUrl.Add(new imageEdit() { url = $"#/File/ShowNoticeImg?filePath={fileName}", alt = "", href = "" });
stream.Close();
}
}
}
return new JsonResult(new { errno = 0, data = fileUrl });
}