I need to validate for file field, if it contains special character whichever is not correct for file field.
I am uploading my file and after it gets uploaded I am not able to open it if it has special charterer.
I need to validate :
1) file name - no special character
2) file size - limit the size
3) file format - video and only .mp4
Note : Thanks for
istos
comment I am using accept attribute but it would not validate, I have to do validation in either JS or PHP.
I am using ajax call for my form instead of using html form
.
I am not sure if I need to do this in client side (jQuery, JS) or server side (PHP) or both site.
Please help, Thanks
$('body').on('change', '#gl_video_file', function(e) {
var glVideoFiles = event.target.files;
glVideoFileSplit = glVideoFiles[0].name.split(".");
glVideoFileFormat = glVideoFileSplit[1];
glVideoFileName = glVideoFileSplit[0].split(' ').join('_')
alert ("File name : "+glVideoFileName)
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="file" placeholder="Video file" class="dupFile" id="gl_video_file">