【发布时间】:2014-04-01 15:11:43
【问题描述】:
我需要这方面的帮助。我已经在 cakephp 中构建了一个 Web 应用程序。在本地主机上一切都很好。图像被正确上传、插入、删除。我上传到服务器的那一刻,它显示错误!
注意(8):未定义索引:Slider [APP/Model/Slider.php, line 245]
注意(8):未定义索引:Slider [APP/Model/Slider.php, line 247]
警告(2): unlink(/home8/ceraunia/public_html/afs/cesi/admin/app/webroot/img/uploads/slider/images/) [function.unlink]: 是一个目录 [APP/Model/Slider.php,第 248 行]
我不知道该怎么做,或者问题出在哪里。正如我在 localhost 中提到的,一切都很完美。我使用的主机服务器是 blueHost。
任何帮助都会非常感谢..
编辑:
这是导致问题的代码:
public function afterSave($created, $options = array()) {
$dir = 'img' . DS . 'uploads' . DS . 'slider' . DS . 'images' . DS; /*<=== DO NOT EDIT*/
// then after deletation of the row we check if the file exist, if so we delete it.
if(isset($this->data[$this->alias]['pic_path']) && file_exists(WWW_ROOT . $dir . $this->image['Slider']['pic_path'])){
$img = WWW_ROOT . $dir . $this->image['Slider']['pic_path'];
unlink($img);
return true;
} else { $this->data[$this->alias]['pic_path'] = $this->image['Slider']['pic_path']; }
return true;
}
【问题讨论】:
-
查看模型 Slider 的第 245 和 247 行可能有用吗?此外,与您的本地主机相比,服务器的某些规格(例如 php 版本)。您没有向我们提供太多信息。
-
我添加了您要求的额外代码行!...我不知道我在这里缺少什么您知道@Nunser 吗?
-
就我所见,不知道
$this->image有什么,该数组根本没有索引。现在,为什么没有它?我不知道,也许首先显示您如何保存这些数据?请添加本地主机和服务器的 php 和 mysql 版本