Re: is_executable() ???

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Al wrote:
clearstatcache();
if(is_executable(PATH_TO_SOURCE_DIR . $filename)
{
code
}

is_executable() will only tell if the execute bit is set for the provided file.


Always returns true for:
foo.jpg
foo.php
foo.sh

And even if I feed it a non existing file.

Checking on a non-existing file basically is checking for the directory.
PATH_TO_SOURCE_DIR . $filename == PATH_TO_SOURCE_DIR if $filename == ""

Directories generally have the permission 0755 which means they have the execute bit set, and hence the "true" result.


I found one ref that said is_executable() doesn't work in safemode, seems dumb if true.

If that's so, how can I test whether an uploaded file is executable?

Any file, under unix can be executable if the execute bit in the file permissions is set.

Make sure you umask settings are correct, so that files created do not have the execute bit set or use chmod on the file after uploading.

If you intend to find if the file is an executable in the Windows sense... is_executable() will not help you.

Try examining the mime type of the file.. (PECL::Fileinfo),
though it may of be of little help.

Additionally, using is_uploaded_file() and move_uploaded_file() functions is recommended while dealing with uploaded content.


I'm on a NIX with Apache, etc.



--
Regards,
Anup Shukla

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux