This is a migrated thread and some comments may be shown as answers.

Clear uploaded selected file from list

1 Answer 17 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Vibhu
Top achievements
Rank 1
Vibhu asked on 05 Aug 2015, 02:03 PM

I want to delete the selected uploaded file from the list on some condition.

Actually I want to allow only PDF files to be uploaded. As soon as I upload I am able to track the file extension and I am able to popup a message that this file is not valid but that file is uploaded and shows RED marked in the uploaded file list on top. I want that file should be removed from the list at that time itself.

Please help me out.

 

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 10 Aug 2015, 12:06 PM
Hello,

You can use the highlighted code below to delete the row with the file not uploaded due to an invalid extension:
function OnClientValidationFailed(sender, args) {
    var fileExtention = args.get_fileName().substring(args.get_fileName().lastIndexOf('.') + 1, args.get_fileName().length);
    if (args.get_fileName().lastIndexOf('.') != -1) {
        //this checks if the extension is correct
        if (sender.get_allowedFileExtensions().indexOf(fileExtention) == -1) {
            alert("Wrong file type!");
            var row = args.get_row();
            row.parentNode.removeChild(row);
        }
        else {
            alert("Wrong file size!");
        }
    }
    else {
        alert("not correct extension!");
    }
}

Regards,
Ivan Danchev
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
AsyncUpload
Asked by
Vibhu
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or