Posts

Showing posts from November, 2018

How to send Send Email with attached CSV file in codeigniter

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Home extends CI_Controller {     public function __construct() { parent::__construct(); $this->load->helper('url'); $this->load->library('email'); $this->load->helper('file'); $this->load->database(); } public function index() {     $data['rs'] =  $this->db->get('customer_profile');     $this->load->view('home', $data);    } // Download for CSV file. // http://localhost/codeigniterR/index.php/home/csv public function csv($query, $filename = 'CSV_Report.csv') { $this->load->dbutil(); $this->load->helper('download'); $delimiter = ","; $newline = "\r\n"; $enclosure = '"'; $query = $this->db->query("select customeremail as Radhey from customers"); $data = $this->dbutil->csv_from_result($query, $delimiter, $newline); // client ...

How to get the parameter from url in codeigniter?

$this -> uri -> segment ( n ); where n = 1 for controller, n = 2 for method and n = 3 for parameter and so on. You need n = 3 to get parameter. In your path localhost/log/job/php , your method name is missing. Even if your method name is index then you route will be localhost/log/job/index/php In case if you need to remove index.php from url then you will get parameter using localhost/log/index.php/job/index/php To remove index.php you need to create .htaccess file by following these steps: Create a .htaccess file where index.php file is located with content RewriteEngine on RewriteCond %{ REQUEST_FILENAME } !- f RewriteCond %{ REQUEST_FILENAME } !- d RewriteRule ^(.*) $ index . php / $1 [ L , QSA ] Make sure that apache can access this .htaccess file. To do this edit apache configuration file. If you use ubuntu, then it is /etc/apache2/sites-available/default and then change AllowOverride none to AllowOverride all for directory and www dir...