mysql - 在服务器中上传图像失败 CAKEPHP

标签 mysql cakephp bluehost

我需要这方面的帮助。我已经在 cakephp 中构建了一个网络应用程序。在本地主机上一切正常。图像被正确上传、插入、删除。当我将其上传到服务器时,它显示错误!

通知(8):未定义索引:Slider [APP/Model/Slider.php,第 245 行]

通知(8):未定义索引:Slider [APP/Model/Slider.php,第 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;
} 

最佳答案

简单地阅读消息怎么样?

/home8/ceraunia/public_html/afs/cesi/admin/app/webroot/img/uploads/slider/images/) [function.unlink]: Is a directory

您正在尝试删除 unlink() 的目录。我想,自从 you're not showing the stacktrace ,另外两个通知来自丢失的文件名。

调试的基础知识:转到通知告诉您的行并调试那里的变量,看看为什么索引未定义。您可以通过跟踪堆栈跟踪已经告诉您的代码路径来弄清楚这一点。

还有另一个猜测:您使用的是 Windows,服务器是 *nix 机器,并且您没有使用 DS 常量作为目录分隔符?

关于mysql - 在服务器中上传图像失败 CAKEPHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22789909/

相关文章:

ruby - 在 Bluehost 上使用 Phusion Passenger 进行 Rails 部署

node.js - 谁可以在bluehost中访问nodejs应用程序?

mysql - MySQL 中的 BIGINT 移位

Python 字典作为文本存储在 MySQL 中

php - cakephp 3 在记录时使用范围

php - CakePHP GET 请求仅在部分时间失败

mysql - CakePHP登录失败

MYSQL:条件 _IN_ 无法正常工作

php - 使用 PHP 更新特定列时的 MySQL 时间戳

php - Cakephp 和具有不常见结构的数据库