【发布时间】:2010-01-11 22:50:27
【问题描述】:
当我选择图像并推送上传时,我的控制器中出现此错误: 注意(8):未定义索引:文件[APP/controllers/garage_car_images_controller.php,第22行]
我还注意到下面显示的 $form->create 行不会在检查的 html 中生成表单代码。这很奇怪。
任何想法如何解决这个问题?谢谢!
我的查看代码:
<div class="title_plate">
<h1 id="title_plate_header">add image</h1>
</div>
<div id="overlay_content">
<?php
echo $form->create('GarageCarImage', array('controller' => 'garage_car_images','action' => 'add', 'type' => 'file'));
echo $form->file('File');
echo $form->hidden('garage_car_id', array('value' => $this->params['pass'][0]));
echo "<br><br>";
echo "Make this image the default? " . $form->input('default', array('type' => 'select', 'label' => false, 'options' => array('0' => 'No', '1' => 'Yes')));
echo "<br>";
echo $form->submit('Upload');
echo $form->end();
?>
</div>
我的控制器代码:
if (!empty($this->data) &&
is_uploaded_file($this->data['GarageCarImage']['File']['tmp_name'])) {
$fileData = fread(fopen($this->data['GarageCarImage']['File']['tmp_name'], "r"),
$this->data['GarageCarImage']['File']['size']);
$this->data['GarageCarImage']['type'] = $this->data['GarageCarImage']['File']['type'];
$this->data['GarageCarImage']['user_id'] = $this->Auth->user('id');
$this->GarageCarImage->save($this->data);
}
【问题讨论】:
-
选择您发布的代码并点击“01 10”按钮(代码)...它将格式化代码以便在此处查看。
-
01 10 按钮是什么意思?
-
知道了...我按照你的要求做了:)
标签: file cakephp forms upload indexing