This is a migrated thread and some comments may be shown as answers.
How to get file name of uploaded and renamed file in FileUploaded() event
1 Answer 41 Views
This is a migrated thread and some comments may be shown as answers.
Tihomir
Top achievements
Rank 1
Tihomir asked on 10 Jun 2011, 01:10 PM
Hi all,
Please can you tell me how can i get a filename of already uploaded and renamed file.
I use FileUploadStarting() event to upload and rename  file (Test.txt -> 123Test.txt).
I want to catch the new file name in FileUploaded() event but I didn't success.

Thanks
P.S. the file is uploaded successfully with the new file name.

1 Answer, 1 is accepted

Sort by
0
Accepted
Alex Fidanov
Telerik team
answered on 15 Jun 2011, 03:04 PM
Hi Tihomir,

You can send the new file name as parameter back to the client from the server. In the RadUploadHandler yuo can ovveride the GetAssociatedData method and return the file name. In the FileUploaded event, you can request the parameter through the HandlerData property:

// code in the handler
public override Dictionary<string, object> GetAssociatedData()
{
    Dictionary<string, object> associatedData = base.GetAssociatedData();
    if (this.IsFinalFileRequest())
    {
        associatedData.Add("NewFileName", this.GetFileName());
    }
    return associatedData;
}

private void upload_FileUploaded(object sender, FileUploadedEventArgs e)
{
    var newName = e.HandlerData.CustomData["NewFileName"];
}


Best wishes,
Alex Fidanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Asked by
Tihomir
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Share this question
or