title: CodeIgniter Fatal error: Call to undefined function
body: <p>I am using CodeIgniter.
  I am reusing a Library for upload file to google drive. Now I am facing error. </p>
  
  <blockquote>
    <p>Fatal error: Call to undefined function upLoadGoogleDriveFile() in
    D:\xampp\htdocs\butfix\Brain-Teaser-Fest\application\controllers\blabla.php
    on line 21</p>
  </blockquote>
  
  <p>Call Stack</p>
  
  <pre><code>Time    Memory  Function    Location
  
  1   0.0499  146680     {main}( )    ..\index.php:0
  2   0.0916  183128     require_once( 'D:\xampp\htdocs\butfix\Brain-Teaser-Fest\system\core\CodeIgniter.php' )   ..\index.php:202
  3   1.2976  3225664    call_user_func_array ( ) ..\CodeIgniter.php:359
  4   1.2976  3225712    Blabla-&gt;index( ) ..\CodeIgniter.php:359
  </code></pre>
  
  <p>Now my Controller Class is :
  blabla.php</p>
  
  <pre><code>&lt;?php
  
  if (!defined('BASEPATH')) {
      exit('No direct script access allowed');
  }
  
  class Blabla extends CI_Controller {
  
      public function __construct() {
          parent::__construct();
          $this-&gt;load-&gt;library('MY_DriveServiceHelper');
          $this-&gt;load-&gt;helper('file');
      }
  
      public function index() {
  
          echo "Welcome to Bulls' warmed leavings";
  
          $path = "butfix" . DIRECTORY_SEPARATOR . "bookstore" . DIRECTORY_SEPARATOR . "filesystem" . DIRECTORY_SEPARATOR . "source" . DIRECTORY_SEPARATOR . "original.jpg";
  
          upLoadGoogleDriveFile($path);
      }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>And my Library Class is :
  MY_DriveServiceHelper.php</p>
  
  <pre><code>&lt;?php
  
  if (!defined('BASEPATH')) {
      exit('No direct script access allowed');
  }
  
  require_once 'google-api-php-client/src/Google_Client.php';
  require_once 'google-api-php-client/src/contrib/Google_DriveService.php';
  
  class MY_DriveServiceHelper {
  
      const BACKUP_FOLDER = 'PHPBackups';
      const SHARE_WITH_GOOGLE_EMAIL = 'my_email@gmail.com';
      const CLIENT_ID = '111111.apps.googleusercontent.com';
      const SERVICE_ACCOUNT_NAME = '123asdf@developer.gserviceaccount.com';
      const KEY_PATH = "asdf-privatekey.p12";
  
      protected $scope = array('https://www.googleapis.com/auth/drive');
      private $_service;
  
      public function __construct() {
  
          $client = new Google_Client();
          $client-&gt;setClientId(self::CLIENT_ID);
  
          $inFile = NULL;
          if (file_exists(self::KEY_PATH)) {
              $inFile = read_file(self::KEY_PATH);
          }
          $client-&gt;setAssertionCredentials(new Google_AssertionCredentials(
                  self::SERVICE_ACCOUNT_NAME, $this-&gt;scope, $inFile)
          );
  
          $this-&gt;_service = new Google_DriveService($client);
      }
  
      public function __get($name) {
          return $this-&gt;_service[$name];
      }
  
      public function createFile($name, $mime, $description, $content,
              Google_ParentReference $fileParent = null) {
          $file = new Google_DriveFile();
          $file-&gt;setTitle($name);
          $file-&gt;setDescription($description);
          $file-&gt;setMimeType($mime);
  
          if ($fileParent) {
              $file-&gt;setParents(array($fileParent));
          }
  
          $createdFile = $this-&gt;_service-&gt;files-&gt;insert($file,
                  array(
              'data' =&gt; $content,
              'mimeType' =&gt; $mime,
          ));
  
          return $createdFile['id'];
      }
  
      public function createFileFromPath($path, $description,
              Google_ParentReference $fileParent = null) {
          $fi = new finfo(FILEINFO_MIME);
          $mimeType = explode(';', $fi-&gt;buffer(read_file($path)));
          $fileName = preg_replace('/.*\//', '', $path);
  
          return $this-&gt;createFile($fileName, $mimeType[0], $description,
                          read_file($path), $fileParent);
      }
  
      public function createFolder($name) {
          return $this-&gt;createFile($name, 'application/vnd.google-apps.folder',
                          null, null);
      }
  
      public function setPermissions($fileId, $value, $role = 'writer',
              $type = 'user') {
          $perm = new Google_Permission();
          $perm-&gt;setValue($value);
          $perm-&gt;setType($type);
          $perm-&gt;setRole($role);
  
          $this-&gt;_service-&gt;permissions-&gt;insert($fileId, $perm);
      }
  
      public function getFileIdByName($name) {
          $files = $this-&gt;_service-&gt;files-&gt;listFiles();
          foreach ($files['items'] as $item) {
              if ($item['title'] == $name) {
                  return $item['id'];
              }
          }
  
          return false;
      }
  
      public function upLoadGoogleDriveFile($path) {
  
          printf("Uploading %s to Google Drive\n", $path);
  
          $folderId = $this-&gt;getFileIdByName(BACKUP_FOLDER);
  
          if (!$folderId) {
              echo "Creating folder...\n";
              $folderId = $this-&gt;createFolder(BACKUP_FOLDER);
              $this-&gt;setPermissions($folderId, SHARE_WITH_GOOGLE_EMAIL);
          }
  
          $fileParent = new Google_ParentReference();
          $fileParent-&gt;setId($folderId);
  
          $fileId = $this-&gt;createFileFromPath($path, $path, $fileParent);
  
          printf("File: %s created\n", $fileId);
  
          $this-&gt;setPermissions($fileId, SHARE_WITH_GOOGLE_EMAIL);
      }
  
  }
  </code></pre>