473,386 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

php fileinfo help needed

bob
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
Jan 22 '08 #1
4 3538
On Jan 22, 11:36 am, bob <lun...@gmail.comwrote:
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:)

Jan 22 '08 #2
On Tue, 22 Jan 2008 10:36:42 +0100, bob <lu****@gmail.comwrote:
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
Jan 22 '08 #3
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 <an*******@freemail.ru>

Jan 22 '08 #4
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 <an*******@freemail.ru>

Jan 22 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Bowman | last post by:
Hi All, ..NET 1.1... I'm wondering if there is any approach more convenient to get a list of FileInfo objects than the following. For example, if I wanted to get 1 list of all the Exe's and all...
1
by: Antonio | last post by:
Good morning, I've the following file system : C: -> HTML -> Aziende -> Azienda_1 -> a.jpg -> Azienda_2 -> a.jpg ... -> Azienda_N -> a.jpg my desire is to create an array of fileinfo...
5
by: Lance | last post by:
I want to expose properties of a class to a user via a PropertyGrid class. Some of the properties are of type System.IO.FileInfo. Ideally, an OpenFileDialog window would appear when the user...
10
by: Michael Murphy | last post by:
Hi, I have a Windows VB.Net app in which I need to keep files in one folder in sync with files in another folder. I have pasted the code below. Can anyone tell me why I end up with a folder with all...
1
by: Michael A. Covington | last post by:
I just saw something like this in someone else's code and am curious... string fname; .... store a filename in fn ... FileInfo fi = new FileInfo(fname); string name = fi.Name;
3
by: rn5a | last post by:
To work with files, when should one use the File class & when should one use the FileInfo class? Similarly, to work with directories, when should one use the Directory class & when should one...
0
by: comp.lang.php | last post by:
if (!function_exists('mime_content_type_fileinfo')) { /** * Will use {@link http://us2.php.net/fileinfo FileInfo} functions provided within {@link http://pecl.php.net PECL} bundle to return mime...
1
by: comp.lang.php | last post by:
<pre> if (!function_exists('mime_content_type_fileinfo')) { /** * Will use {@link http://us2.php.net/fileinfo FileInfo} functions provided within {@link http://pecl.php.net PECL} bundle to return...
1
by: bob | last post by:
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 =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.