Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9232547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:20:24+00:00 2026-06-18T06:20:24+00:00

controller <?php if ( ! defined(‘BASEPATH’)) exit(‘No direct script access allowed’); class Upload extends

  • 0

controller

  <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

    class Upload extends CI_Controller {

            function __construct(){
                parent::__construct();
                $this->load->helper(array('form', 'url'));
            }

            function index()
            {
                $this->load->view('uploaderview', array('error' => ' ' ));
            }

            function do_upload(){
                $config['upload_path'] = './upl0d/';
                $config['allowed_types'] = 'gif|jpg|png';
                $config['max_size'] = '2048'; //2mb
                $config['max_width']  = '1024';
                $config['max_height']  = '768';
                $config['encrypt_name'] = FALSE;
                $config['overwrite'] = FALSE;

                $this->load->library('upload', $config);

                if ( ! $this->upload->do_upload()){
                    $error = array('error' => $this->upload->display_errors());
                    $this->load->view('uploaderview', $error);
                }
                else{
                    ## Insert into filesystem.
                    $data = array('upload_data' => $this->upload->data());
                    ## load the success page.
                    $this->load->view('uploadsuccess', $data);
                    ## Insert into db
                    ## then insert the img name into the database
                    $this->load->model('uploadermodel');
                    $this->uploadermodel->uploadcoupon();               
                }
            }
    }
    ?>

model

   <?php

    class Uploadermodel extends CI_Model{

        function __construct(){
            // Call the Model constructor
            parent::__construct();
        }

        function uploadcoupon($data){
            $uploadFileName = $this->upload->data();
            $currentDt = date('Y-m-d H:i:s');
            $data = array('fileNameUploaded'=>$uploadFileName,'date'=>$currentDt);
            $this->db->insert('Coupon', $data); 
        }

    }   
    ?>

I’m trying to gather the value of $config['file_name'] and send it with my model. How do I do so? Currently it’s trying to upload: VALUES (Array, '2013-02-03 20:20:01')

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:20:25+00:00Added an answer on June 18, 2026 at 6:20 am

    You now have an array $data with a key ‘upload_data’ (you don’t actually need to do it this way – I wish they would fix the docs, but leave it)

    So, do a var_dump($data[‘upload_data’]) and you will see all the information about the file you just uploaded.

    Going from memory, there will be something like $data[‘upload_data’][‘file_name’]…

    So, just pass that value plus your full insert data to your model.

    $this->uploadermodel->uploadcoupon(); 
    

    Need to have $data passed…

    $this->uploadermodel->uploadcoupon($data);
    

    don’t try to grab it from $this->upload like you are doing

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Go extends CI_Controller
I have a controller: landingpage.php <?php if ( ! defined('BASEPATH')) exit('No direct script access
I have a controller called landingpage.php <?php if ( ! defined('BASEPATH')) exit('No direct script
This is how my controller looks like <?php defined('SYSPATH') or die('No direct script access.');
<?php class Email extends Controller { function Email() { parent::Controller(); $this->load->library('email'); } function index()
This is my Controller // No direct access defined( '_JEXEC' ) or die( 'Restricted
<?php class PI_Controller_Plugin_AssetGrabber extends Zend_Controller_Plugin_Abstract { public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { /* The module
Here is the content of file User.php <?php class My_Controller_Plugin_User extends Zend_Controller_Plugin_Abstract { public
I am getting the following error: The autoloader expected class Acme\HelloBundle\Controller\HelloController to be defined
I've got a class library in defined here .../projectname/library/Me/Myclass.php defined as follows: <?php class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.