We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I get the uploaded filename on the server after a successfull uplaoid

Thread ID:





119710 Jul 23,2015 02:54 PM UTC Jan 5,2018 11:00 AM UTC ASP.NET Web Forms 4
Tags: Uploadbox
David Farmer
Asked On July 23, 2015 02:54 PM UTC

Hi, I'm using your asp.net Uploadbox control with the associated handler files for Save and delete file. The upload process is working correctly but I'm having difficulty retrieving the uploaded file(s) name on the server after upload. The UploadBox_Complete event is firing but I can't get the file names.


David Farmer
Replied On July 27, 2015 10:21 AM UTC

Got this working;

Private Sub UploadBox_Complete(sender As Object, e As Syncfusion.JavaScript.Web.UploadBoxCompleteEventArgs) Handles UploadBox.Complete

Dim strName As String

Dim data As Dictionary(Of String, Object) = e.FileStatus

For Each keyval As KeyValuePair(Of String, Object) In data

If keyval.Key = "name" Then

strName = keyval.Value.ToString

End If


End Sub

Ezhil S [Syncfusion]
Replied On July 29, 2015 05:23 AM UTC

Hi David,

Thanks for sharing your code.
We are glad that your issue have been resolved.

Get back to us if you have further queries.

Ezhil S

Replied On January 4, 2018 08:05 AM UTC


In “.ashx” file I'm changing the original file name to randomly generated file name.  I want randomly generated saved file name and the path (path on server) in "UploadBox_Complete" event handler. Can you please help on this front ? 

Prince Oliver [Syncfusion]
Replied On January 5, 2018 11:00 AM UTC

Hi KnjayGmail, 

Thank you for contacting Syncfusion forums. 

We can send the newly generated file name and its path as JSON object via the response text that is returned from the handler. Refer to the following code. 

public class saveFiles : IHttpHandler 
    public void ProcessRequest(HttpContext context) 
        List<uploadFile> Uploadfiles = new List<uploadFile>(); 
        string targetFolder = HttpContext.Current.Server.MapPath("uploadfiles"); 
        if (!Directory.Exists(targetFolder)) 
        HttpRequest request = context.Request; 
        HttpFileCollection uploadedFiles = context.Request.Files; 
        if (uploadedFiles != null && uploadedFiles.Count > 0) 
            for (int i = 0; i < uploadedFiles.Count; i++) 
                string fileName = uploadedFiles[i].FileName; 
                Uploadfiles.Add(new uploadFile { oldname = fileName, newname = "Randomly Generated Name here", path = targetFolder }); 
                int indx = fileName.LastIndexOf("\\"); 
                if (indx > -1) 
                    fileName = fileName.Substring(indx + 1); 
                uploadedFiles[i].SaveAs(targetFolder + "\\" + fileName); 
        var json = JsonConvert.SerializeObject(Uploadfiles); 
        context.Response.ContentType = "text/json"; 
    public bool IsReusable 
            return false; 
public class uploadFile 
    public string oldname { get; set; } 
    public string newname { get; set; } 
    public string path { get; set; } 

We can access the response text in the Uploadbox’s success event. Kindly refer to the following code. 

<ej:UploadBox ID="Upload1" SaveUrl="saveFiles.ashx" RemoveUrl="removeFiles.ashx" runat="server" ClientSideOnSuccess="fileuploadSuccess" ></ej:UploadBox> 
    function fileuploadSuccess(e) { 
        var FileData = JSON.parse(e.responseText)[0]; 
        alert("New Name: " + FileData.newname); 
        alert("Path: " + FileData.path); 

We have prepared a sample as per your requirement, please find the sample from the following location:  http://www.syncfusion.com/downloads/support/forum/119710/ze/UBmodifiedName-1902696265 



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon