0

我正在构建一个应用程序,在该应用程序中,当用户提交表单时,我有一个包含多个文件上传的表单,然后是 foreach 循环捕获的所有帖子值,如下所示

if($booker->setsessions($_POST))
{
$this->redirect(array('controller'=>'homes','action'=>'step_four'));
}
else
{
    $this->setFlashMsg('Please Provide Valid Information','message-box ok');
}

在这里它正在捕捉帖子值

foreach($data as $index=>$value){
    $this->$index=$value;
}
$this->save();  
$booking->booker_id =$this->id;
$booking->save();

public function save() 
{   
    if (!$this->id) {
        $this->create();
    }
    else {
        $this->update();
    }
}

protected function create()
{
    $connection = db::factory('mysql');

    $sql = "insert into {$this->table} (`";
    $sql .= implode('`, `', array_keys($this->values));
    $sql .= "`) values ('";

    $clean = array();
    foreach ($this->values as $value) {
        $clean[] = $connection->clean($value);
    }

    $sql .= implode("', '", $clean);
    $sql .= "')";

    $this->id = $connection->insertGetID($sql);
}

这里 $this->save(); 获取所有 $index=>values 并插入到一个表中,我的表单看起来像这样

    <form class="form-3 form-horizontal ajxfrm" id="step-three" enctype="multipart/form-data" action="<?php echo $html->addLink(array('controller'=>'homes','action'=>'step_three_ajax')); ?>" method="post">
    <input id="name" type="text" name="name" />
    <input id="email" type="text" name="email" />
    <input id="city" type="text" name="city" />
     <input id="contact" type="text" name="contact" />
     <input id="fileupload" type="file" name="fileupload[]" />

所以在这里我想通过mysql上传表中的所有数据和另一个表中的文件,但是上面的代码正在获取所有的帖子值并试图插入一个没有文件列的表中,所以它给了我一个错误

4

0 回答 0