开发者

Finding the install path of a utility with PHP on linux/freebsd/macosx

I have a PHP code block I've written that uses imagemagick's convert program (called through exec()) to create thumbn开发者_StackOverflow社区ails of uploaded images (originally we tried using the PHP module calls, but kept running into memory errors).

Of course to do this I have to have the full path to convert, which varies from system to system (on my mac it's at /opt/local/bin/convert). I've been just looking it up on the server and setting it in a constant, but this is often less than ideal.

My question is, is there a way to programmatically lookup the install path of convert? I can then just store it in the database or something for quick lookup.


If "convert" is in the include path for a user,

 $path = `which convert`; 

should find it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜