Skip to content

Instantly share code, notes, and snippets.

@edomaru
Created March 28, 2016 16:30
Show Gist options
  • Save edomaru/b27605aad57ca3c2f0d3 to your computer and use it in GitHub Desktop.
Save edomaru/b27605aad57ca3c2f0d3 to your computer and use it in GitHub Desktop.
store other post when uplaod
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Site extends CI_Controller {
public function upload()
{
if ( ! empty($_FILES))
{
$config['upload_path'] = "./assets/uploads";
$config['allowed_types'] = 'gif|jpg|png|mp4|ogv';
$this->load->library('upload', $config);
if (! $this->upload->do_upload("file")) {
echo "File cannot be uploaded";
}
}
// here example to store other post data to database
if (count($_POST)) {
$upload_data = $this->upload->data();
$this->db->insert('table_name', array(
'title' => $_POST['title'],
'description' => $_POST['description'],
'image' => $upload_data['file_name']
));
}
$this->listFiles();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment