../MAdminWTRegistrationDocuments/CretificateOfInCorporation14022024152400.jpg this is my image in registration now i want to edit the userdetails to update show the image url in fileupload controller how to do this
Get the file name in fileuploadcontroller
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.


Jayraj ChhayaRank #304 · 8.2K reputationPosted Mar 11, 2024, 2:10 AM EDT
Hi,
To retrieve the file name in the FileUploadController, you can extract it from the provided image URL. In a .NET environment, you can use the
Path.GetFileNamemethod to get the file name from the URL. Here's a sample code snippet to achieve this:using System.IO; public class FileUploadController : Controller { public ActionResult UpdateUserDetails() { string imageUrl = "../MAdminWTRegistrationDocuments/CretificateOfInCorporation14022024152400.jpg"; string fileName = Path.GetFileName(imageUrl); // Use the fileName in your update logic // Update user details with the fileName return View(); } }By utilizing
Path.GetFileName, you can extract the file name "CretificateOfInCorporation14022024152400.jpg" from the image URL.