|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 ![]() |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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> |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
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> |
|
![]() |
| Outils de la discussion | |
|
|