1
我是codeigniter的新手。 我嘗試使用phpmyadmin數據庫,我有麻煩編輯記錄。
A PHP Error was encountered
Severity: Notice
Message: Undefined property: stdClass::$file
Filename: controllers/arsip.php
Line Number: 137
在目錄控制器arsip.php的這一部分是行號顯示錯誤
function edit($id)
{
$judul = $this->input->post('no',TRUE);
$config['file_name'] = $judul;
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'pdf|doc|docx';
$config['max_size'] = '1000000';
$data['title']="Edit data Arsip";
$this->_set_rules();
$this->load->library('upload', $config);
$this->upload->initialize($config);
$files = (object) $_FILES;
$f_data = (object) $files->file; //is problem
$file=$this->upload->file_name;
$id = $this->input->post("no");
if ($this->form_validation->run() == FALSE)
{
$result["msg"] = validation_errors();
;
$result["success"] = false;
}
elseif($f_data->name != "")
{
if (!$this->upload->do_upload("file")) {
$result["content"] = $this->upload->display_errors("", "");
$result["success"] = false;
}
else
{
$fdata = (object) $this->upload->data();
$data = array(
'no_arsip'=>$this->input->post('no'),
'tahun'=>$this->input->post('tahun'),
'nama_kapal'=>$this->input->post('nama_kapal'),
'perihal'=>$this->input->post('perihal'),
'file' => $fdata->file_name,
);
$this->m_arsip->update($id,$info);
$data['arsip']=$this->m_arsip->cek($id)->row_array();
$data['message']="<div class='alert alert-success'>Data berhasil diupdate</div>";
redirect('arsip');
}
}
else
{
$data = array(
'no_arsip'=>$this->input->post('no'),
'tahun'=>$this->input->post('tahun'),
'nama_kapal'=>$this->input->post('nama_kapal'),
'perihal'=>$this->input->post('perihal'),
);
$this->m_arsip->update($id,$info);
$data['arsip']=$this->m_arsip->cek($id)->row_array();
$data['message']="<div class='alert alert-success'>Data berhasil diupdate</div>";
redirect('arsip');
}
echo json_encode($result);
}
爲什麼要把它作爲一個對象?爲什麼不使用'$ _FILES'的聯合索引? – Ghost 2014-09-25 03:22:53
文件html元素的名稱是什麼? – 2014-09-25 05:23:52