<!----------------------File-------------------------->
<input type="file" value="" id="i_file" />
<input type="button" value="Submit" id="i_submit" />
<input type="button" value="Submit" id="i_submit" />
<!-------------------Script--------------------->
$('#i_submit').click( function() {
//check whether browser fully supports all File API
if (window.File && window.FileReader && window.FileList && window.Blob)
{
//get the file size and file type from file input field
var fsize = $('#i_file')[0].files[0].size;
var ftype = $('#i_file')[0].files[0].type;
var fname = $('#i_file')[0].files[0].name;
switch(ftype)
{
case 'image/png':
case 'image/gif':
case 'image/jpeg':
case 'image/pjpeg':
alert("Acceptable image file!");
break;
default:
alert('Unsupported File!');
}
}else{
alert("Please upgrade your browser, because your current browser lacks some new features we need!");
}
});
//check whether browser fully supports all File API
if (window.File && window.FileReader && window.FileList && window.Blob)
{
//get the file size and file type from file input field
var fsize = $('#i_file')[0].files[0].size;
var ftype = $('#i_file')[0].files[0].type;
var fname = $('#i_file')[0].files[0].name;
switch(ftype)
{
case 'image/png':
case 'image/gif':
case 'image/jpeg':
case 'image/pjpeg':
alert("Acceptable image file!");
break;
default:
alert('Unsupported File!');
}
}else{
alert("Please upgrade your browser, because your current browser lacks some new features we need!");
}
});
ConversionConversion EmoticonEmoticon