Hi nauna,
Please refer below sample.
HTML
<asp:ToolkitScriptManager runat="server">
</asp:ToolkitScriptManager>
<asp:AjaxFileUpload ID="AjaxFileUpload11" runat="server" MaximumNumberOfFiles="5"
Width="400px" OnUploadComplete="OnUploadComplete" />
Namespaces
C#
using System.IO;
using AjaxControlToolkit;
Vb.Net
Imports System.IO
Imports AjaxControlToolkit
Code
C#
protected void OnUploadComplete(object sender, AjaxFileUploadEventArgs e)
{
string fileName = Path.GetFileName(e.FileName);
string ext = Path.GetExtension(e.FileName);
if (ext == ".jpg" || ext == ".jpeg" || ext == ".gif" || ext == ".png")
{
fileName = Guid.NewGuid().ToString() + ext;
}
AjaxFileUpload11.SaveAs(Server.MapPath("~/Uploads/" + fileName));
}
VB.Net
Protected Sub OnUploadComplete(ByVal sender As Object, ByVal e As AjaxFileUploadEventArgs)
Dim fileName As String = Path.GetFileName(e.FileName)
Dim ext As String = Path.GetExtension(e.FileName)
If ext = ".jpg" OrElse ext = ".jpeg" OrElse ext = ".gif" OrElse ext = ".png" Then
fileName = Guid.NewGuid().ToString() & ext
End If
AjaxFileUpload11.SaveAs(Server.MapPath("~/Uploads/" & fileName))
End Sub