From what i understand for asp.net FileUpload.FileName ruturns the full path while in firefox it returns just the filename. How would i remove the path from the returned string as i just need the html encoded filename.
Solution 1. filePath = FileUpload1. PostedFile. FileName; //gets only file name.
ASP. NET's FileUpload is an input controller used to upload files to a server. It appears on the screen with a browse button and opens up a dialogue box to choose a file or multiple files to upload from the local storage to the server. This is a server-side control provided by ASP.NET.
You can use the Path static class to get the filename.
var fileName = Path.GetFileName(somePath);
And the HttpUtility static class to encode it.
var encoded = HttpUtility.HtmlEncode(fileName);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With