将图像保存在cakephp之外,将其保存到codeigniter assets文件夹cakephp上传插件

时间:2014-06-11 07:18:57

标签: php codeigniter cakephp image-uploading

我正在为cakePHP使用josegonzalez/cakephp-upload插件。最初它将上传的图像存储到app/webroot/img/files/[modelname]/[idname]。但是cakePHP在我的案例中用于CodeIgniter安装,我想将我的图片保存到assets的{​​{1}}目录中。有没有可能的方法来编辑上传插件的CodeIgniter?我试过这个,

UploadBehavior

我已将 'rootDir' => '/localhost/ci_installation/', 'pathMethod' => 'primaryKey', 'path' => '{ROOT}assets{DS}images{DS}{model}{DS}', 修改为rootDir的本地安装,但上传后,图片未存储在CI位置。有人可以帮我这个吗?请?非常感谢你。

1 个答案:

答案 0 :(得分:2)

你必须改变路径'它使用ROOT global(cakephp)和你想要的路径。 改变这一行:

 '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或指向您所需位置的内容

选中此Global constant and functions CakePHP Cookbook