包含10行的4列仪表板
提供,其中用户可以输入
详情如下:
Column 1 – File Category
Column 2 – File Type
Column 3 - File Reference
Column 4 – Upload FIle (any type)
上传按钮 - 上传详情 输入的所有文件 同时
我无法上传数据库中的所有记录,只有最后一次录音保存在DATABASE中,请帮助我
UserControlle.php(我的控制器)
<?php
App::uses('AppController', 'Controller');
class FilesController extends AppController
{
public $helpers=array('Html','Form');
public $components = array('RequestHandler');
/*function to display all files details*/
public function index()
{
$this->set('Files', $this->File->find('all'));
}
/*function to add file record into the database */
public function add()
{
if ($this->request->is('post'))
{
$this->File->create();
if(empty($this->data['File']['url']['name']))
{
unset($this->request->data['url']['file']);
}
if(!empty($this->data['File']['url']['name']))
{
$file=$this->data['File']['url'];
$file['name']=$this->sanitize($file['name']);
$this->request->data['File']['url'] = time().$file['name'];
if($this->File->save($this->request->data))
{
move_uploaded_file($file['tmp_name'], APP . 'outsidefiles' .DS. time().$file['name']);
return $this->redirect(array('action' => 'index'));
$this->Session->setFlash(__('Your File has been saved.'));
//return $this->redirect(array('action' => 'index'));
}
}
$this->Session->setFlash(__('Unable to add your File.'));
}
}
}
add.ctp(我的观点)
<h1>Add File</h1>
<?php
echo $this->Form->create('File',array('enctype'=>'multipart/form-data'));
echo $this->Form->input('category', array(
'options' => array( 'passport' => 'Passport', 'pancard' => 'Pancard', 'driving license' => 'Driving License', 'others' => 'Others')
));
echo $this->Form->input('type', array(
'options' => array( 'image' => 'Image', 'office' => 'Office', 'technical' => 'Technical', 'others' => 'Others')
));
echo $this->Form->input('reference');
echo $this->Form->input('url', array('type' => 'file'));
echo $this->Form->input('category', array(
'options' => array( 'passport' => 'Passport', 'pancard' => 'Pancard', 'driving license' => 'Driving License', 'others' => 'Others')
));
echo $this->Form->input('type', array(
'options' => array( 'image' => 'Image', 'office' => 'Office', 'technical' => 'Technical', 'others' => 'Others')
));
echo $this->Form->input('reference');
echo $this->Form->input('url', array('type' => 'file'));
echo $this->Form->input('category', array(
'options' => array( 'passport' => 'Passport', 'pancard' => 'Pancard', 'driving license' => 'Driving License', 'others' => 'Others')
));
echo $this->Form->input('type', array(
'options' => array( 'image' => 'Image', 'office' => 'Office', 'technical' => 'Technical', 'others' => 'Others')
));
echo $this->Form->input('reference');
echo $this->Form->input('url', array('type' => 'file'));
echo $this->Form->end('Save File');
答案 0 :(得分:0)
这个批量如何保存?看起来您正在将上传的文件保存到数据库中。命名模型public Form1(pcbSerialPort pcb)
{
PCB = pcb;
}
也不是一个好主意,因为它与可能导致一系列问题的核心类冲突。
通常,如果您要批量插入,则需要读取CSV中的行,循环显示这些行,然后在每个行上调用File
和create()
。