0
當我選擇的圖像,並推上傳,得到這個錯誤在我的控制器: 通知(8):未定義指數:文件[APP /控制器/ garage_car_images_controller.php,第22行]文件上載錯誤cakephp的
我也注意到下面顯示的$ 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」按鈕(代碼)...它將格式化代碼以在此查看。 – dlamotte 2010-01-11 22:52:39
01 10按鈕是什麼意思? – 2010-01-11 22:59:21
明白了......我做了你所要求的:) – 2010-01-11 23:01:10