/// <returns></returns>
public ActionResult UploadImages(string path)
{
string rsPath = string.Empty;
if (Request.Files.Count > 0)
{
foreach (string key in Request.Files)
{
var file = this.Request.Files[key];
if (file == null)
{
continue;
}
if (file.ContentLength == 0)
{
continue;
}
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path);
string extension = Path.GetExtension(file.FileName);
string fileName = Guid.NewGuid() + extension;
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
string originalImagePath = Path.Combine(filePath, fileName);
string image60 = Guid.NewGuid() + extension;
string image200 = Guid.NewGuid() + extension;
string image400 = Guid.NewGuid() + extension;
string image60Path = Path.Combine(filePath, image60);
string image200Path = Path.Combine(filePath, image200);
string image400Path = Path.Combine(filePath, image400);
file.SaveAs(originalImagePath);
ThumbnailHelper.MakeThumbnail(originalImagePath, image60Path, ThumbnailSizeMode.SpecifiedWidthAndHeightContain, ImageFormat.Jpeg, 60, 60);
ThumbnailHelper.MakeThumbnail(originalImagePath, image200Path, ThumbnailSizeMode.SpecifiedWidthAndHeightContain, ImageFormat.Jpeg, 200, 200);
ThumbnailHelper.MakeThumbnail(originalImagePath, image400Path, ThumbnailSizeMode.SpecifiedWidthAndHeightContain, ImageFormat.Jpeg, 400, 400);
rsPath = "/" + path + image60 + ";/" + path + image200 + ";/" + path + image400;
}
}
return Json(new { result = rsPath });
}
public ActionResult UploadImages(string path)
{
string rsPath = string.Empty;
if (Request.Files.Count > 0)
{
foreach (string key in Request.Files)
{
var file = this.Request.Files[key];
if (file == null)
{
continue;
}
if (file.ContentLength == 0)
{
continue;
}
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path);
string extension = Path.GetExtension(file.FileName);
string fileName = Guid.NewGuid() + extension;
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
string originalImagePath = Path.Combine(filePath, fileName);
string image60 = Guid.NewGuid() + extension;
string image200 = Guid.NewGuid() + extension;
string image400 = Guid.NewGuid() + extension;
string image60Path = Path.Combine(filePath, image60);
string image200Path = Path.Combine(filePath, image200);
string image400Path = Path.Combine(filePath, image400);
file.SaveAs(originalImagePath);
ThumbnailHelper.MakeThumbnail(originalImagePath, image60Path, ThumbnailSizeMode.SpecifiedWidthAndHeightContain, ImageFormat.Jpeg, 60, 60);
ThumbnailHelper.MakeThumbnail(originalImagePath, image200Path, ThumbnailSizeMode.SpecifiedWidthAndHeightContain, ImageFormat.Jpeg, 200, 200);
ThumbnailHelper.MakeThumbnail(originalImagePath, image400Path, ThumbnailSizeMode.SpecifiedWidthAndHeightContain, ImageFormat.Jpeg, 400, 400);
rsPath = "/" + path + image60 + ";/" + path + image200 + ";/" + path + image400;
}
}
return Json(new { result = rsPath });
}