Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Admin panel - allow the store owner to override logo file

KrzysztofPajakaf0bf07cf6e1
diff --git a/src/Web/Grand.Web.Admin/Controllers/PictureController.cs b/src/Web/Grand.Web.Admin/Controllers/PictureController.cs
index c18750c63..a9eb1bcbd 100644
--- a/src/Web/Grand.Web.Admin/Controllers/PictureController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/PictureController.cs
@@ -251,12 +251,28 @@ namespace Grand.Web.Admin.Controllers
});
}
}
- return Json(new
+ else
{
- success = false,
- message = "This filename exists"
- });
-
+ var filepath = _mediaFileStore.GetDirectoryInfo("");
+ if (filepath != null)
+ {
+ using (var stream = new FileStream(_mediaFileStore.Combine(filepath.PhysicalPath, fileName), FileMode.OpenOrCreate))
+ {
+ httpPostedFile.CopyTo(stream);
+ }
+ return Json(new
+ {
+ success = true,
+ imageUrl = fileName
+ });
+ }
+ else
+ return Json(new
+ {
+ success = false,
+ message = "Physical path not exist"
+ });
+ }
}
}