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: 2187
- 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;
Add below:
Code: Select all
use File::MMagic;
use FileHandle;
Find:
Code: Select all
my (@fileslots,@filenames,@filenames2,@file_status);
and replace it with
Code: Select all
my (@fileslots,@filenames,@filenames2,@filetype,@file_status);
Find:
Code: Select all
&SaveFile2( ${$cg->{'.tmpfiles'}->{$k}->{name}}, $c->{target_dir}, $filename );
Add above:
Code: Select all
my $mmagic = new File::MMagic;
my $mime = $mmagic->checktype_filename( ${$cg->{'.tmpfiles'}->{$k}->{name}} );
and add below:
Code: Select all
push @filetype, $mime;
so the esulting code is:
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;
Finally, find:
Code: Select all
push @har, { name=>"$fileslots[$_]", 'value'=>$filenames2[$_] };
Add below:
Code: Select all
push @har, { name=>"$fileslots[$_]_mime", 'value'=>$filetype[$_] };