[Koha] How to check a file's MIME type in KOHA

Jonathan Druart jonathan.druart at bugs.koha-community.org
Tue Feb 14 23:12:08 NZDT 2017


Hi Rejeesh,

I have just written a patch using CGI->uploadInfo.
I think it does what you want.
See bug 18087, patch 'Handle invalid filetypes'.

Regards,
Jonathan

On Tue, 14 Feb 2017 at 07:11 Rejeesh K.Nair <rejeeshknair at gmail.com> wrote:

> Hi All,
>
> Many thanks for all your timely support , We got a solution for checking
> MIME type. Here I am sharing the code snippet I have used to solve it .
> Please see the code and share your comments.
>
> my $file = $query->param("id_list_file");
> my $tmpfilename = $query->tmpFileName($file);
> my $mimeinfo = `file -i -b $tmpfilename`;
> my @fields = split /;/, $mimeinfo;
> my $mimetype = $fields[0];
> #print $mimetype;
> if($mimetype eq 'application/marc' ){
> //Required action
> }else{
> //Required action
> }
>
> Regards,
> Rejeesh
>
> On Wed, Feb 8, 2017 at 2:03 PM, Holger Meissner <
> Holger.Meissner at hs-gesundheit.de> wrote:
>
> > Hi Rejeesh,
> >
> > there are a few ways to execute a system command from perl code. You can
> > use
> > http://perldoc.perl.org/functions/system.html
> >
> > Not sure if that's the best solution.
> >
> > Regards
> > Holger
> >
> > Rejeesh K.Nair wrote:
> > > Hi Mark,
> > >
> > > Your sample code meets my requirement. But I need to implement this for
> > each uploading file in KOHA code.
> > >
> > > Regards,
> > > Rejeesh K.Nair
> > _______________________________________________
> > Koha mailing list  http://koha-community.org
> > Koha at lists.katipo.co.nz
> > https://lists.katipo.co.nz/mailman/listinfo/koha
> >
>
>
>
> --
> Thanks & Regards,
>
> Rejeesh K.Nair
> m: +91 (0) ​9495316906 <+91%2094953%2016906>
> e: rejeeshknair at gmail.com
> <https://www.facebook.com/rejeeshnairk> <https://twitter.com/rejeeshknair>
> <http://in.linkedin.com/in/rejeeshknair>
> <https://www.instagram.com/rejeeshknair/>
> _______________________________________________
> Koha mailing list  http://koha-community.org
> Koha at lists.katipo.co.nz
> https://lists.katipo.co.nz/mailman/listinfo/koha
>


More information about the Koha mailing list