【发布时间】:2016-04-24 18:51:18
【问题描述】:
我是 Codeigniter 的新手。我需要帮助上传图片和视频并将其保存到文件夹和数据库。
这是我的控制器
public function upload()
{
$this->m_upload->upload();
$this->upload_gambar();
}
public function upload_gambar()
{
//load the helper
$this->load->helper('form');
$config['upload_path'] = 'assets/gallery/images';
$config['allowed_types'] = 'gif|jpg|png|mp4';
$config['max_size'] = '';
$this->load->library('upload', $config);
$this->upload->initialize($config);
$this->upload->set_allowed_types('*');
$data['upload_data'] = '';
$this->upload->do_upload('uploadan');
redirect(c_upload);
}
这是我的模型
public function upload()
{
$title = $this->input->post('title');
$details = $this->input->post('details');
$type = $this->input->post('gallery');
$picture = $_FILES['uploadan']['name'];
$data = array(
'url' => $picture,
'title' => $title,
'details' => $details,
'category' => $type
);
$this->db->insert('gallery', $data);
}
我已经在 php.ini 中设置了 upload_max_filesize 和 post_max_size 但它仍然无法正常工作。请帮我解决这个问题。谢谢你
【问题讨论】:
-
那是 php 代码。但是如果我想通过 codeigniter 来做呢?
-
如果一切都失败了,你总是可以look at the manual
-
欢迎来到 SO。
it still not working:请编辑问题并描述会发生什么(发布错误消息,如果有的话?) -
@RiggsFolly 当前和旧的codeigniter 文档现在位于codeigniter 主网站codeigniter.com/docs
标签: php codeigniter