0

在我的表格中,我有:

<input type="file" name="data[Speciality][background_image]" id="background_image" class="hide">

这是控制器中“捕获”的请求数据:

public 'data' => 
    array (size=3)
      'modified' => string '0' (length=1)
      'Speciality' => 
        array (size=2)
          'name' => string 'addfsdfsdf' (length=10)
          'background_image' => string 'test.jpg' (length=8)

如您所见,仅提供了文件名,它应该是这样的:

[name] => test.jpg
[type] => image/jpeg
[tmp_name] => C:\server\tmp\php5A.tmp
[error] => 0
[size] => 560

怎么了?

4

1 回答 1

2

您可能忘记阅读有关如何处理文件上传的文档。

确保你的 create() 方法中有 type=>file :

echo $this->Form->create('Speciality', array('type' => 'file'));

http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#options-for-create

于 2013-02-25T14:50:49.617 回答