Editor -File Upload validation with MIME type
Editor -File Upload validation with MIME type
soluciones
Posts: 12Questions: 5Answers: 0
in General
Hi,
I need to use MIME type to check file content validation in file upload.
How can I implement it?
This discussion has been closed.
Replies
A custom validator would be the way to do this.
$file['type']
will give you the MIME type.Allan
But how to validation MIME type before upload the file?
For example, in preSubmit event? How to access image properties?
editor.on( 'preSubmit', function ( e, o, a ) {
var files =this.val( 'trabajos.file_id' );
The
preUpload
event is how to do this on the client-side. It will give the mime type as part of the third parameter.Remember to check it on the server-side as well though, since client-side validation can always be bypassed.
Allan
And how can I check it on the server-side?
Can you give me an example for MIME TYPE? I have validations for size and extensions
->validator( function ( $file ) {
Thanks,
Almost exactly the same as your file size validator:
Allan
I have this code
return $file['type'] !== 'image/jpeg' or $file['type'] !== 'image/jpg' ?
"Wrong file type " . $file['type'] :
null;
But I have uploaded a .svg image renamed as .jpg and allows it
If you debug the code, what is it giving
$file['type']
as?Allan