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 8220321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:29:04+00:00 2026-06-07T13:29:04+00:00

Hi this is a simple question, however I have now stared at it long

  • 0

Hi this is a simple question, however I have now stared at it long enough to realise im simply not seeing the error. If anyone can see where this is going wrong I would be very thankful.

public function create()
{
$this->load->model('ticket_model');

if($_POST)
    {
    // validate form
    if($this->_validate())
        {
        // save updates                                 
        foreach($_POST as $key => $value){if(!is_array($value)) $_POST[$key] = htmlspecialchars($value);}

        if ($_POST['subject'] == '')    $body_data['error'][] = "You did not enter a subject.";
        if ($_POST['priority'] == '')   $body_data['error'][] = "You did not select a priority.";
        if ($_POST['status'] == '')     $body_data['error'][] = "You did not select a status.";
        if ($_POST['ipAddress'] == '')  $body_data['error'][] = "You did not enter a ipAddress.";
        if ($_POST['text_area'] == '') $body_data['error'][] = "You did not enter a message.";
        else
            {
            if (filter_var($_POST['ipAddress'], FILTER_VALIDATE_IP,  FILTER_FLAG_IPV4) == FALSE) $body_data['error'][] = "IP Address is not valid IPV4 Address.";
            if (filter_var($_POST['ipAddress'], FILTER_VALIDATE_IP,  FILTER_FLAG_NO_PRIV_RANGE) == FALSE) $body_data['error'][] = "IP Address cannot be from RFC1918 private space.";
            if (filter_var($_POST['ipAddress'], FILTER_VALIDATE_IP,  FILTER_FLAG_NO_RES_RANGE) == FALSE) $body_data['error'][] = "IP Address cannot be from reserved range.";
            }
        if ($_FILES['filename']['name'] != '')
            {
            if ($_FILES['filename']['size'] > '1024000')
                {
                $body_data['error'][]                       = "The file you uploaded is too large.";

                unlink($_FILES['filename']['tmp_name']);

                $body_data['ticket_list']       = $this->ticket_model->list_ticket();
                $body_data['ticket_details']    = $this->ticket_model->get_ticket($ticket_id);
                $body_data['ticket_summary']    = $this->ticket_model->list_ticket_summary($ticket_id);

                $body_data['precan_list']       = $this->ticket_model->list_messages();
                $body_data['users_list']        = $this->ticket_model->list_users();
                $foot_data['accordian_active'] = 5;

                $this->load->view('head',$head_data);
                $this->load->view('sidebar/service',$head_data);
                $this->load->view('ticket/edit',$body_data);
                $this->load->view('foot',$foot_data);
                return;
                }
            else
                {
                //the file is under the specified size. so copy it from temp to import folder and proccess
                $thisFileHumanName      = $_FILES['filename']['name'];
                $thisFileSize           = $_FILES['filename']['size'];
                $thisServerFileName     = strtoupper(uniqid('A'));
                $thisFileType           = $_FILES['filename']['type'];

                $temp_file_location = $this->config->item('rootpath').'/assets/ticketuploads/'.$thisServerFileName;

                if (!move_uploaded_file($_FILES['filename']['tmp_name'], $temp_file_location))
                    {
                    $body_data['error'][]                       = "File could not be moved due to a permissions error.";

                    unlink($_FILES['filename']['tmp_name']);

                    $body_data['ticket_list']       = $this->ticket_model->list_ticket();
                    $body_data['ticket_details']    = $this->ticket_model->get_ticket($ticket_id);
                    $body_data['ticket_summary']    = $this->ticket_model->list_ticket_summary($ticket_id);

                    $body_data['precan_list']       = $this->ticket_model->list_messages();
                    $body_data['users_list']        = $this->ticket_model->list_users();
                    $foot_data['accordian_active'] = 5;

                    $this->load->view('head',$head_data);
                    $this->load->view('sidebar/service',$head_data);
                    $this->load->view('ticket/edit',$body_data);
                    $this->load->view('foot',$foot_data);
                    return;
                    }
                }
            }

        //clean error array
        $body_data['error']                     = array_filter($body_data['error']);

        if ($body_data['error'])
            {
            $body_data['ticket_list']       = $this->ticket_model->list_ticket();
            $body_data['ticket_details']    = $this->ticket_model->get_ticket($ticket_id);
            $body_data['ticket_summary']    = $this->ticket_model->list_ticket_summary($ticket_id);

            $body_data['precan_list']       = $this->ticket_model->list_messages();
            $body_data['users_list']        = $this->ticket_model->list_users();

            unlink($_FILES['filename']['tmp_name']);

            $foot_data['accordian_active'] = 5;

            $this->load->view('head',$head_data);
            $this->load->view('sidebar/service',$head_data);
            $this->load->view('ticket/edit',$body_data);
            $this->load->view('foot',$foot_data);
            return;
            }
        else
            {   

            $_POST['userId'] = $this->session->get_user_id();

            $thisMessageId = $this->ticket_model->save_message($_POST);

            if ($_FILES['filename']['name'] != '')
                {
                //set variables for save
                $_POST['file_path'] = $temp_file_location;
                $_POST['file_name'] = $thisFileHumanName;

                $_POST['file_size'] = $thisFileSize;
                $_POST['file_type'] = $thisFileType;
                $_POST['messageId'] = $thisMessageId;

                $this->ticket_model->save_upload($_POST);
                }
            $this->ticket_model->save_ticket($_POST);

            redirect(base_url().'ticket/');
            return;
            }
        }
    }
$body_data['ticket_list']        = $this->ticket_model->list_ticket();
$body_data['message_list']       = $this->ticket_model->list_message($ticket_id);
$body_data['customer_list']      = $this->ticket_model->list_customers();
$body_data['users_list']         = $this->ticket_model->list_users();

$foot_data['accordian_active'] = 5;
$foot_data['contact_search']   = true;
$this->load->view('head',$head_data);
$this->load->view('sidebar/service',$head_data);
$this->load->view('ticket/create',$body_data);
$this->load->view('foot',$foot_data);
return;
}

This is my code, and everything is going well, except for the section where i save the upload, as nothing seems to be firing the model, even thought there is a file being posted from the from submit and there for the filename being posted is != ''……
e.g

if ($_FILES['filename']['name'] != '')
{
    //set variables for save
    $_POST['file_path'] = $temp_file_location;
    $_POST['file_name'] = $thisFileHumanName;

    $_POST['file_size'] = $thisFileSize;
    $_POST['file_type'] = $thisFileType;
    $_POST['messageId'] = $thisMessageId;

    $this->ticket_model->save_upload($_POST);
}

my apologies if this is silly mistake.

  • 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-07T13:29:05+00:00Added an answer on June 7, 2026 at 1:29 pm

    Why are you doing it this way? Codeigniter has a built in class for uploading files. You also should be using the input class instead of $_POST.
    It will make it a lot easier!

    As for your code. You’re actually setting the $_POST variable and trying to use that in save_ticket. You can’t do that.

    The predefined $_POST variable is used to collect values from a form
    sent with method=”post”

    You’re trying to use it the other way around.

    So to make it work, change the $_POST into $something and it should work, but it’s still not the way to go.

    //set variables for save
    $something['file_path'] = $temp_file_location;
    $something['file_name'] = $thisFileHumanName;
    
    $something['file_size'] = $thisFileSize;
    $something['file_type'] = $thisFileType;
    $something['messageId'] = $thisMessageId;
    
    $this->ticket_model->save_upload($something);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple question; right now I have something like this: typedef void(*MyFunctionPointer)(int); typedef std::vector <
This is kind of a simple question, however, I don't seem to figure out
i have this simple question please. I have this part of code which sets
this is a simple question. I have a form that is being validated using
maybe a very simple question, however I have no idea what I do wrong,
Now similar question(s) has been asked at other places. However, I have tried the
This question might be a bit sketchy because I do not have the code
Sorry for this simple question, but I can't solve it... There is an example:
A simple answer to this super simple question would be great! Here is the
I searched and searched for an answer for this seemingly simple question in Commerce

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.