Can't use finfo_file()?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Can't use finfo_file()?

Post by Chalks »

I'm building an image uploader as a small project, and ran across some issues when trying to validate the files. Here's the error I'm getting: "Fatal error: Call to undefined function finfo_open() in /home/chalks/public_html/test/backend.php on line 33". Why is that happening?

Also: after searching devnetwork, google, and the php manual I've come across these methods for validating files:
finfo_file()
something with the image library (get image size?)
check file extensions (not very good way to validate, but might as well throw it in too)

Are there other methods for validation? Right now I'm testing on a linux server, but I'm going to have to put this on a windows server too. :(
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: Can't use finfo_file()?

Post by nowaydown1 »

Sounds like the PECL extension isn't enabled on your PHP installation. That function isn't part of the base PHP install. Installation instructions for the extension can be found here:

http://us.php.net/manual/en/fileinfo.installation.php
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Can't use finfo_file()?

Post by pickle »

getimagesize() is most often used to verify if a file is an image.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply