XUpload - Mime types check for free version?
Mime types check for free version?
Hi, i'm using the free version of XUpload. I can see it checks the extension of the uploaded files, but i'd like to know if it checks the mime type too. It's not that safe to check only the extension.
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm
Ok, never mind. I just installed File::Magic and now i check the mime type and send it in POST after the upload as you said, here are the changes for those interested:
Find:
Add below:
Find:
and replace it with
Find:
Add above:
and add below:
so the esulting code is:
Finally, find:
Add below:
Find:
Code: Select all
use File::Copy;
Code: Select all
use File::MMagic;
use FileHandle;
Code: Select all
my (@fileslots,@filenames,@filenames2,@file_status);
Code: Select all
my (@fileslots,@filenames,@filenames2,@filetype,@file_status);
Code: Select all
&SaveFile2( ${$cg->{'.tmpfiles'}->{$k}->{name}}, $c->{target_dir}, $filename );
Code: Select all
my $mmagic = new File::MMagic;
my $mime = $mmagic->checktype_filename( ${$cg->{'.tmpfiles'}->{$k}->{name}} );
Code: Select all
push @filetype, $mime;
Code: Select all
my $mmagic = new File::MMagic;
my $mime = $mmagic->checktype_filename( ${$cg->{'.tmpfiles'}->{$k}->{name}} );
&SaveFile2( ${$cg->{'.tmpfiles'}->{$k}->{name}}, $c->{target_dir}, $filename );
push @filetype, $mime;
Code: Select all
push @har, { name=>"$fileslots[$_]", 'value'=>$filenames2[$_] };
Code: Select all
push @har, { name=>"$fileslots[$_]_mime", 'value'=>$filetype[$_] };