2012-07-29 82 views
-2

我得到我的網頁上這個錯誤安全方面的原因:警告:EXEC()已禁用

警告:EXEC()已因安全原因禁止在/ home/a2297145 /的public_html /安卓/指數.PHP上線2036

下面的代碼:

// 
// Determine the size of a file 
// 
public static function getFileSize($file) 
{ 
    $sizeInBytes = filesize($file); 

    // If filesize() fails (with larger files), try to get the size from unix command line. 
    if (EncodeExplorer::getConfig("large_files") == true || !$sizeInBytes || $sizeInBytes < 0) { 
     $sizeInBytes=exec("ls -l '$file' | awk '{print $5}'"); 
    } 
    return $sizeInBytes; 
} 

你能幫我解決這個問題?

+6

您必須與您的主機提供商交談......他們已禁用了exec命令的使用......請閱讀警告信息;) – craig1231 2012-07-29 18:06:30

+2

獲取具有64位PHP安裝的提供程序,並且該函數將變得毫無意義。 – 2012-07-29 18:08:02

+3

Duplicate:http://stackoverflow.com/questions/1837451/exec-has-been-disabled-for-security-reasons-undefined-variable – 2012-07-29 18:08:57

回答

2

錯誤的含義正是它所說的。無論誰設置你的服務器(可能是你的虛擬主機)都禁止使用exec函數。換句話說,您不能使用exec

你可以通過使用glob來獲取文件的文件或filesize來獲得文件的大小(以字節爲單位)來解決它。