Mime types check for free version?

XUpload related questions

Moderator: admin

Message
Author
kkez
Posts: 2
Joined: Jul 18, 2007 4:37 pm

Mime types check for free version?

#1 Postby kkez » Jul 18, 2007 4:45 pm

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.

User avatar
PilgrimX182
Posts: 2182
Joined: Mar 22, 2006 1:39 pm
Location: UFO Lab
Contact:

#2 Postby PilgrimX182 » Jul 19, 2007 5:21 am

No, it's not checking mime types.
Pro version send MIME type in POST after upload so you can decide what to do with the file.

kkez
Posts: 2
Joined: Jul 18, 2007 4:37 pm

#3 Postby kkez » Jul 20, 2007 10:16 am

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:

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[$_] };


Return to “XUpload”

Who is online

Users browsing this forum: No registered users and 0 guests