保存图片在cakephp外,保存到coigniter资产文件夹cakephp上传插件


save images outside cakephp, save it to codeigniter assets folder cakephp upload plugin

我使用josegonzalez/cakephp-upload插件cakePHP。最初,它将上传的图像存储到app/webroot/img/files/[modelname]/[idname]。但是在我的情况下,cakePHP是在CodeIgniter安装中使用的,我想将我的图像保存到CodeIgniterassets目录中。是否有可能编辑上传插件的UploadBehavior ?我试过了,

    'rootDir' => '/localhost/ci_installation/',
    'pathMethod' => 'primaryKey',
    'path'  => '{ROOT}assets{DS}images{DS}{model}{DS}',

我编辑了rootDir到我本地安装的CI,但上传后,图像没有存储在/localhost/ci_installation/assets/images/位置。有人能帮我一下吗?好吗?非常感谢。

您必须将使用ROOT全局(cakephp)的'path'更改为您想要的路径。修改这一行:

 'path'  => '{ROOT}assets{DS}images{DS}{model}{DS}',

 'path'  => '{CI_IMG_ROOT}assets{DS}images{DS}{model}{DS}',

并添加到Config/bootstrap.php

 define('CI_IMG_ROOT','/whatever-root-dir-you-want-here/')

将ROOT更改为CT_IMG_ROOT或其他将指向所需位置的内容

查看全局常量和函数CakePHP Cookbook