我对代码点火器还不熟悉。我尝试使用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);
}发布于 2014-09-25 14:15:33
每当您遇到错误时,例如:
Message: Undefined property: stdClass::$file这意味着PHP可以判断是在查看一个stdClass对象,但是它找不到(在本例中)属性"file“。
若要调试此选项,请执行以下操作:
在$files = (object) $_FILES;之后和$f_data = (object) $files->file;之前写:
die(var_vump($files)); 这将告诉您实际填充对象的内容。
另外,我猜输入的type="file“名称没有设置为"file”,这就是为什么PHP在对象中找不到它的原因。
希望这能有所帮助!
https://stackoverflow.com/questions/26029925
复制相似问题