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

[Solved] Validating Upload File Size And Type on Client Side

2 Answers 168 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Naser
Top achievements
Rank 1
Naser asked on 23 Apr 2012, 05:53 PM
Hi.
How can I check a file type and file size when using a  radUpload in a gird popup window at client side?
  

2 Answers, 1 is accepted

Sort by
0
Accepted
Pechka
Top achievements
Rank 1
answered on 24 Apr 2012, 06:59 AM
This is the event you search for 
http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-upload-client-api-and-events.html#OnSelect 

Also keep in mind different browsers provide different information about the files.
0
Naser
Top achievements
Rank 1
answered on 24 Apr 2012, 04:38 PM
Thanks I Solve my problem with this code :
<script type="text/javascript">
    function onSelect(e) {
        // Array with information about the uploaded files
        var files = e.files;
 
        if (files[0].size > 1048576) {
            alert("File Size Can't be more than 1MB");
            e.preventDefault();
        }
        if (files[0].extension != ".jpg") {
            alert("Just Pictures Files Are Allowed");
            e.preventDefault();
        }
    }
</script>

it work on chrom and ie for me.
Thank you Pechka.
Tags
Upload
Asked by
Naser
Top achievements
Rank 1
Answers by
Pechka
Top achievements
Rank 1
Naser
Top achievements
Rank 1
Share this question
or