如何在PHP中检查文件是否是可执行程序(或被动数据文件)


How to check if a file is executable program (or a passive data file) in PHP?

我试图阻止直接上传可执行文件类型。有没有可靠的方法来检查文件是可执行程序还是只是被动数据文件?

例如:

example.exe // Directly runable, consider dangerous
example.txt // Not Directly runable, consider "safe"
example.bat // Directly runable?, consider dangerous
example.doc // Not Directly runable, consider "safe"

嗯,有is_executable()。