【发布时间】:2018-11-02 18:04:24
【问题描述】:
我正在尝试编辑将图像上传到我的数据库。但是图像字段没有得到值,出来的字段是空的。
查看:
<?php foreach($blog as $b){?>
<form method="post" action="<?php echo site_url('adminUpdatePost/'.$b->id); ?>" class="col s12">
<div class="row">
<div class="input-field col s12">
<textarea id="textarea1" name="textarea1" class="materialize-textarea"><?=$b->post?></textarea>
<label for="textarea1">Post</label>
</div>
</div>
<div class="file-field input-field">
<div class="btn">
<span>Post Image</span>
<input type="file" name="file">
</div>
<div class="file-path-wrapper">
<input id="image" name="image" class="file-path validate" placeholder="<?=$b->image?>" type="text">
</div>
</div>
<input type="submit" value="Submit">
</form>
<?php } ?>
控制者:
public function updatePost($id)
{
$config = array(
'upload_path' => 'uploads/',
'allowed_types' => 'gif|jpg|jpeg|png',
'max_size' => 0,
'filename' => url_title($this->input->post('file')),
'encrypt_name' => false,
);
$this->load->library('upload', $config);
$this->upload->do_upload('file');
$post=array(
'post'=>$this->input->post('textarea1'),
'image'=>$this->upload->file_name, //image
);
ChromePhp::log("edit data : " . json_encode($post));
$result = $this->AdminModel->updatePost($post, $id);
}
使用 ChromePhp 检查 $post 数组的内容时,“图像”显示空值。但是“帖子”有价值。
我找不到哪里出错了。我哪里出错了?
【问题讨论】:
标签: php codeigniter