NYCPHP Meetup

NYPHP.org

[nycphp-talk] file -ib? Re: Using $FILES["whatever"]["type"] correctly

Eric Persson eric at persson.tm
Wed Jan 14 17:27:30 EST 2004


Webapprentice . wrote:

> Eric,
> I'm not well-versed in UNIX.  How do I invoke a command-line program in PHP?  Is there something like a system() call in some other languages? 
> 
> --Stephen

Yes, sure is, I attached my function below:

function file_type($src){
	$exec = '/usr/bin/file -ib '.$src;
	exec($exec, $return);
	if( is_array($return) && isset($return[0]) ){
		return trim($return[0]);
	}else{
		return false;
	}
}

make sure to change the path to your file program, but I think this is a 
somewhat standard place.

see the difference between system() and exec() and you'll see why I'm 
using exec().

//Eric



--
Help Webaid.se help the world.
http://www.webaid.se



More information about the talk mailing list