cakephp - Cakephp 3图像上传如何从模型中保存文件名
问题描述
我正在尝试将文件名保存在模型中。
我已经使用下面的代码实现了在模型中上传文件的代码
$validator
->add('image',[
'mimeType' => [
'rule' => ['mimeType',['image/jpg', 'image/png', 'image/jpeg']],
'message' => 'Please upload only jpg and png.',
'last' => true,
],
'processImageUpload'=>[
'rule' => 'processImageUpload',
'provider' => 'table',
'message' => 'Unable to process cover image upload.',
],
]);
return $validator;
在 processImageUpload 我想保存文件名。但是名字没有保存
public function processImageUpload($check = array()) {
// upload file code here working fine
$this->image = 'uploads/'. $check['name']; //not working
return TRUE;
}
如何从我的模型方法中将图像名称保存在图像字段中?
版本:3.8.4
解决方案
推荐阅读
- python - 使用 python selenium 的 execute_script() 的 ScrollHeight 大小返回不变的结果
- java - 广播接收器未触发
- ruby-on-rails - Why does the object id change following failed validations in a rails controller?
- angular - Intellij IDEA 导入错误的 RxJS 类
- python-3.x - Python3:这两个关于整数除法的计算有什么区别
- python - Python 3 Upgrade: uninstall/reinstall 3.6-3.7 — Now I cannot install Django 2.1: Error msg: [ No module named Django ]
- reactjs - Create Custom prop which calls a function React Native
- stanford-nlp - StanfordNLP OpenIE:获取最佳三元组以匹配演示
- jupyter - Jupyter 笔记本数据保存在哪里?
- ios - Pagination until the end