PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > php fileinfo needed
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
php fileinfo needed

Réponse
 
LinkBack Outils de la discussion
Vieux 22/01/2008, 09h36   #1
bob
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut php fileinfo needed

I am having trouble getting the PHP PECL fileinfo component to work. I
am using Cakephp 1.2, XAMPP in WIndows Vista environment.

I have the following code:
$file = "C:\xampp\htdocs\app\webroot\pics\file.jpg";

$handle = finfo_open(FILEINFO_COMPRESS,'c:/magic');//
FILEINFO_COMPRESS,"c:/magic");
if (!$handle) {
echo "Opening fileinfo database failed";

}

$mime_type = finfo_file($handle,$file);

I get the following output:
Opening fileinfo database failed
Warning (2): finfo_file(): supplied argument is not a valid file_info
resource [APP\controllers\users_controller.php, line 198]

I put the magic.mime file in the C:\ directory. I also added the
extension=php_fileinfo.dll line in the php.ini file.

Thanks in advance
  Réponse avec citation
Vieux 22/01/2008, 10h42   #2
_q_u_a_m_i_s's
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: php fileinfo needed

On Jan 22, 11:36 am, bob <lun...@gmail.com> wrote:
> I am having trouble getting the PHP PECL fileinfo component to work. I
> am using Cakephp 1.2, XAMPP in WIndows Vista environment.
>
> I have the following code:
> $file = "C:\xampp\htdocs\app\webroot\pics\file.jpg";
>
> $handle = finfo_open(FILEINFO_COMPRESS,'c:/magic');//
> FILEINFO_COMPRESS,"c:/magic");
> if (!$handle) {
> echo "Opening fileinfo database failed";
>
> }
>
> $mime_type = finfo_file($handle,$file);
>
> I get the following output:
> Opening fileinfo database failed
> Warning (2): finfo_file(): supplied argument is not a valid file_info
> resource [APP\controllers\users_controller.php, line 198]
>
> I put the magic.mime file in the C:\ directory. I also added the
> extension=php_fileinfo.dll line in the php.ini file.
>
> Thanks in advance


I`m not sure how its on windows..but 'c:/magic' ?? shouldn`t it be 'c:
\magic'? From what i see here, $handle is either false, or null.
Either case $handle should be a resource id, not null.

From the manual:
"A .mime and/or .mgc suffix is added if needed."


Return Values
Returns a magic database resource on success or FALSE on
failure. ..... so your call to finfo_open failed

  Réponse avec citation
Vieux 22/01/2008, 12h13   #3
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: php fileinfo needed

On Tue, 22 Jan 2008 10:36:42 +0100, bob <lunet3@gmail.com> wrote:

> I am having trouble getting the PHP PECL fileinfo component to work. I
> am using Cakephp 1.2, XAMPP in WIndows Vista environment.
>
> I have the following code:
> $file = "C:\xampp\htdocs\app\webroot\pics\file.jpg";


Either use '/' or '\\' as path seperator.
--
Rik Wasmus
  Réponse avec citation
Vieux 22/01/2008, 17h03   #4
AnrDaemon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: php fileinfo needed

Greetings, _q_u_a_m_i_s's.
In reply to Your message dated Tuesday, January 22, 2008, 13:42:39,

> I`m not sure how its on windows..but 'c:/magic' ?? shouldn`t it be
> 'c:\magic'?


No. There is absolutely no difference between '\' and '/' when working with
filesystem under DOS or Windows.


--
Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru>

  Réponse avec citation
Vieux 22/01/2008, 17h09   #5
AnrDaemon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: php fileinfo needed

Greetings, bob.
In reply to Your message dated Tuesday, January 22, 2008, 12:36:42,

> I have the following code:
> $file = "C:\xampp\htdocs\app\webroot\pics\file.jpg";


Try to print() this variable value and You'll see Your problem.
Rule to work with strings:
Do NOT use double-quotes unless You absolutely sure You need them.
So, either
$file = 'C:\xampp\htdocs\app\webroot\pics\file.jpg';
or (as rick said) this way
$file = "C:/xampp/htdocs/app/webroot/pics/file.jpg";

But much safer and portable way is to use forward-slashes even with
single-quoted string.

$file = 'C:/xampp/htdocs/app/webroot/pics/file.jpg';


--
Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h55.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11733 seconds with 13 queries