Product Bundles
DevCraft
All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:
Web
Mobile
Document Management
Desktop
Reporting
Testing & Mocking
CMS
UI/UX Tools
Debugging
Free Tools
Support and Learning
Productivity and Design Tools
I have set the TargetFolder e.g.
TargetFolder="~/content"
and it works fine except that i want the file names to be kind od hashed e.g. myfile.jpg to be saved as 8unfsKjfjskskdjf^7i.jpg
I have the HashFileName(string file) function but not quite sure where to apply it.
Thank you
protected
void
Unnamed_FileUploaded(
object
sender, Telerik.Web.UI.FileUploadedEventArgs e)
{
// Get the file object
var file = e.File;
// Get file name and extension as string array
var fileNameAndExtension = file.GetName().Split(
new
char
[]{
'.'
});
// Set a random string as file name
fileNameAndExtension[0] =
"RandomString"
;
// Join new name with file extension
var finalName = fileNameAndExtension[0] +
"."
+ fileNameAndExtension[1];
// Set pah to folder on server
string
path = Server.MapPath(
"~/Uploads/"
);
// Save file with the new name in the given path
file.SaveAs(path + finalName);
}