Skip to content

Repository files navigation

codeigniter-upload

Codeigniter 3 – Upload file and insert data into database!

Basic Setup:

MYSQL PART:

Go to MySQL or open phpMyadmin and create a database name called 'codeigniter3' and then create a table called 'pictures'. I am attaching the table structure here:

CREATE TABLE `pictures` (
`pic_id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`pic_title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`pic_desc` text COLLATE utf8_unicode_ci NOT NULL,
`pic_file` varchar(255) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

MySQL part is over. No need to go to the database again.

CODEIGNITER CONFIGURATIONS:

  1. First, open the database.php file inside /codigniter3/application/config/database.php and change the mysql hostname, username and password as per your database server configuration:
$db['default'] = array(
'dsn'	=> '',
'hostname' => 'localhost',//change this as per your server
'username' => 'root',//change this as per your server
'password' => '', //change this as per your server
'database' => 'codeigniter3',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
  1. Then, open config.php file inside /codigniter3/application/config/config.php and set the $config['base_url'] to $config['base_url'] = 'http://localhost/codeigniter3/';

About

Codeigniter 3 – Upload file and insert data into database!

Topics

Resources

Contributing

Stars

6 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages