Cakephp文件上传字符损坏

时间:2014-09-08 05:19:35

标签: cakephp cakephp-2.3

我想使用表单来设置用户数据。 这是我的代码。进入日语时会出现乱码。 但是,当我排除'type'=>时它很有效。 '文件'。 配置和数据库设置为utf8 all。 请给出建议。

echo $this->Form->create('User', array('url' => array('controller' => 'Users', 'action' => 'userprofileedit',$user_id ),'type' => 'file'));
echo $this->Form->input('upfile', array('label' => array('text' => 'upfile'),'type' => 'file'));
echo $this->Form->input('nickname',array('label' => array('text' => 'nickname'),"value"=>$nickname));
echo $this->Form->end(__('Save'));

1 个答案:

答案 0 :(得分:0)

如果要为用户上传文件,请替换表单创建:

echo $this->Form->create('User', array(
    'url' => array('controller' => 'Users', 'action' => 'userprofileedit',$user_id ),
    'type' => 'file'
));

使用:

echo $this->Form->create('User', array(
    'enctype' => 'multipart/form-data'
    'url' => array('controller' => 'Users', 'action' => 'userprofileedit',$user_id ),
));

还要确保你的app / core.php有:

Configure::write('App.encoding', 'UTF-8');
相关问题