我在我的photocategories_controller.php
文件中爲我的admin_add
設置了以下代碼。這段代碼在我的CentOS開發服務器中非常適用。但是,當我將此文件上傳到我的生產服務器時,它不起作用。任何幫助將不勝感激〜CakePHP mkdir無法在生產服務器上工作
function admin_add() {
.... //Other code here
//On folder add, get its ID to be used as the name of the folder
$folderID = $this->Photocategory->getLastInsertId();
//This directory is already created
$uploadDir = '/img/uploads/photos/';
$serverRoot = $_SERVER['DOCUMENT_ROOT'];
//Folder location to be created. When I print it I get
// /home/xxxxxxx/public_html/img/uploads/photos/16 === 16 being the last inserted ID
$directoryPath = $serverRoot.$uploadDir.$folderID;
//I CANNOT FIGURE OUT WHAT AM I DOING WRONG HERE. IT WORKS IN MY DEVELOPMENT
//SERVER, BUT NOT IN MY PRODUCTION SERVER
if(mkdir($directoryPath, 0777)){
if(mkdir($directoryPath."/thumb", 0777)){
$this->Session->setFlash('Success', 'default', array('class' => 'alert_success'));
}else{
$this->Session->setFlash('Error creating thumb', 'default', array('class' => 'alert_error'));
}
}else{
$this->Session->setFlash('Error Creating Directory', 'default', array('class' => 'alert_error'));
}
大膽猜測:權限問題。顯然你的www數據不允許在這個文件夾中寫入。 –