Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <input type="file" name="photo" id="photo" onchange="checkfile(this);" />
- function checkfile(sender) {
- var validExts = new Array(".zip", ".rar", ".pdf", ".jpeg", ".jpg", ".png", ".tif", ".gif", ".JPG");
- var fileExt = sender.value;
- fileExt = fileExt.substring(fileExt.lastIndexOf('.'));
- if (validExts.indexOf(fileExt) < 0) {
- alert("Invalid file selected, valid files are of " +
- validExts.toString() + " types.");
- return false;
- }
- else return true;
- }
- var uploadField = document.getElementById("file");
- uploadField.onchange = function() {
- if(this.files[0].size > 307200){
- alert("File is too big!");
- this.value = "";
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement