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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:38:20+00:00 2026-06-14T03:38:20+00:00

Hi I’m having some trouble about the upload file part. Well basically I have

  • 0

Hi I’m having some trouble about the upload file part. Well basically I have a form with upload logo part wherein if a user doesn’t select a logo he/she can still update his/her profile at the same time the user can also choose to upload a logo but it has some limitations. Now I don’t know how I can validate that part to know if he/she chooses an image or not. Here’s my code so far in CI controller:

if (//CHECK IF THERE IS A FILE FOR UPLOAD){
                $new_name = $data['id'];

                $config['upload_path'] = './Logos/';
                $config['allowed_types'] = 'jpg|png|gif';
                $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');
                    }
                }

The part in if is where I wanted to set a validations. I tried some tricks but all of those doesn’t work properly.

Here’s my view part where if the logo of the certain ID already exists it’s just display his/her logo or else displays the default logo:

 <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>
  • 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-14T03:38:21+00:00Added an answer on June 14, 2026 at 3:38 am

    I usually get native PHP to check if the file is being uploaded before getting CI’s upload class to do the job:

    if (isset($_FILES['upload_field_name']) && is_uploaded_file($_FILES['upload_field_name']['tmp_name'])) {
        //load upload class with the config, etc...
        $this->load->library('upload', $config);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have a reasonable size flat file database of text documents mostly saved in
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the

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.