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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:17:50+00:00 2026-06-14T12:17:50+00:00

Hi I wanted to upload a 100 x 100 pixel image as a logo

  • 0

Hi I wanted to upload a 100 x 100 pixel image as a logo on my website for each user. It works on my localhost but doesn’t work online (image is not uploaded). Well the concept is simple I just upload it and rename the image base on their ID’s then display it on their page for them to view it. Another thing, the localhost version changes the image on the specified path but doesn’t display it after upload somethimes but sometimes it works just fine. Well that not a big case here I just think that it might be a clue for solving this problem. Here’s my code so far:

this is declared on top:

$data['base'] = $this->config->base_url();
$data['check_error'] = false;
$data['error_message'] = array();
$data['id'] = $this->session->userdata('id');

This is the code:

if (isset($_FILES['userfile']) && is_uploaded_file($_FILES['userfile']['tmp_name'])){
                    $new_name = $data['id'];

                $config['upload_path'] = './Logos/';
                $config['allowed_types'] = 'jpg|png|gif';
                $config['encrypt_name'] = true;
                $config['max_size'] = '100';
                $config['max_width']  = '100';
                $config['max_height']  = '100';

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

                    if ( ! $this->upload->do_upload())
                    {
                        array_push($data['error_message'], "You have the following errors in your entry:\n");
                        array_push($data['error_message'], "- Logo must be 100x100 pixels in size not exceeding 100KB with JPG,PNG or GIF format");
                        array_push($data['error_message'], "\nLogo upload failed.");
                        $data['check_error'] = true;
                    }
                    else
                    {
                        $data = array('upload_data' => $this->upload->data());

                        //DO UPDATE PART HERE
                        $file = $data['upload_data']['file_name'];
                        rename($config['upload_path'] . $file, $config['upload_path'] .$new_name.'.jpg');
                        //GO TO SETTINGS
                        $this->load->helper('url');  
                        redirect($data['base'].'settings');

                    }
                }

HTML:

 <tr>
    <td><p class="titles">Logo</p></td>
    <td>
    <div>
        <input type="text" id="fileName" class="file_input_textbox" readonly="readonly">

        <div class="file_input_div">
          <input type="button" value="Browse" class="file_input_button" />
          <input type="file" class="file_input_hidden" onchange="javascript: document.getElementById('fileName').value = this.value" id="upload" name="userfile" />
        </div>
    </div>
    </td>
</tr>

<tr>
<td>
</td>
<td>
<p class="titles">100px x 100px jpg, png or gif only.</p>
</td>
</tr>

<tr>
<td><p class="titles">Current Logo</p></td>
<td>
    <img src="<?php if(is_array(@getimagesize($base."Logos/".$id.".jpg"))){echo $base."Logos/".$id.".jpg";}else{echo $base."Logos/default.jpg";} ?>"  style="margin:0px 0px 0px 90px;"/>
</td>
</tr>

I also use CodeIgniter_2.1.3 and 5.4.3 in PHP locally and 5.2.17 online. Going nuts haha!

  • 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-14T12:17:51+00:00Added an answer on June 14, 2026 at 12:17 pm

    You should look into the file name part. Firstly you have set the condition encrypt_name to true. While you anyway rename your file to the id this is not neccesary.
    You set the new filename to be equal to

    $data['id'].".jpg" 
    

    this will never work if uploaded file is a GIF or PNG image…

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

Sidebar

Related Questions

I wanted to upload a jpeg image file on the server.I have a GoAhead
I am developing a website in PHP that let the user to upload images
I wanted to upload an audio file to a website and I want to
I wanted to find a way to upload a single file*, in the background,
I wanted to knw if there is way we can upload /download a blob;
I just wanted to know how to configure FCKEditor to upload files and images
Wanted to see if anyone knows how to add props to a image with
I'm working on this big website and I want to put it online before
I wanted to design a simple site where one person can upload a file,
i have a page where the user can upload files on the server. Due

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.