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

  • Home
  • SEARCH
  • 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 3996916
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:20:15+00:00 2026-05-20T07:20:15+00:00

I just started programming a week or two ago, so I apologize for the

  • 0

I just started programming a week or two ago, so I apologize for the potential terrible code, but I’ve been having a hard time figuring this one thing out.
I’ve managed to get the files to upload to the designated destination, but I just can’t get the resize/image manipulation tool to work.

The code that’s giving me the problem is the commented out section, and I’ve already made sure to give the folders the proper privileges. Any help would be outstanding.

I’ve also been curious about how I would use absolute paths for something like this:

function avatar_update() {
    $config['upload_path'] = './avatars/';
    $config['allowed_types'] = 'jpg';
    $config['max_size'] = '100';
    $config['max_width'] = '100';
    $config['max_height'] = '100';
    $config['file_name'] = time();

    $filename = $config['file_name'];

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

    if (!$this->upload->do_upload()) {
        $error = $this->upload->display_errors();
        $this->session->set_flashdata('msg', $error);
        $this->load->view('General/header');
        $this->load->view('profile_view', $error);
        $this->load->view('General/footer');

    } else {
        // $this->load->library('image_lib');

        // $resize['image_library'] = 'gd2';
        // $resize['source_image'] = './avatars/'.$filename.'.jpg';
        // $resize['maintain_ratio'] = TRUE;
        // $resize['create_thumb'] =TRUE;
        // $resize['width'] = 50;
        // $resize['height'] = 50;

        // $this->load->library('image_lib', $resize);

        // $this->image_lib->resize();

        $username = $this->session->userdata('username');
        $avatar = array(
            'avatar' => $filename
        );

        $this->db->where('username', $username);
        $this->db->update('users', $avatar);

        $this->db->select();
        $this->db->where('username', $username);
        $query = $this->db->get('users');

        if ($query->num_rows() > 0) {
            $user_details = $query->row_array();

        }

        $this->session->set_userdata($user_details);

        $this->load->view('General/header');
        $this->load->view('profile_view');
        $this->load->view('General/footer');
    }
}
  • 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-05-20T07:20:16+00:00Added an answer on May 20, 2026 at 7:20 am

    Your code looks ok to me (except for loading the image library twice!). Try adding a path for the new image into your config array.

    $resize['new_image'] = '/path/to/new_image.jpg';
    

    You shouldn’t need it, but it might be worth a try!
    Also, as per my comment you should wrap the resize() function in conditionals so you can test and echo any errors.

    PS. When you get more used to CI and the MVC model think about moving all your db logic to a model.

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

Sidebar

Related Questions

I just started studying programming about 6 months ago and I have really been
I have just started reading through The C Programming Language and I am having
Just started programming in C++. I've created a Point class, a std::list and an
I just started programming in C# and was reading about dividing your application /
I just started programming with objects recently and am trying to learn good habits
I just started programming in Xcode and I'm trying to write an iphone application.
I've just started programming with POSIX threads on dual-core x86_64 Linux system. It seems
I have just started programming and have made a few small applications in C
How would you explain to someone who has just started programming in Java, what
Sorry for this, I've just started programming with wpf. I can't seem to figure

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.