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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:35:53+00:00 2026-06-13T01:35:53+00:00

I have a problem , I took me 2 hours but I couldn’t solve

  • 0

I have a problem , I took me 2 hours but I couldn’t solve it.

When I want to upload multiple images (3 images ) it will upload but then I can’t create a thumb for all , just for the first picture , I don’t know where is the problem

this is my form

<form action="" method="post" enctype="multipart/form-data">
<input type="file" id="hotel_img1" value="upload" name="hotel_img1">
<input type="file" id="hotel_img2" value="upload" name="hotel_img1">
<input type="file" id="hotel_img3" value="upload" name="hotel_img1">
<input type="submit">
</form>

this is my code
controller

<?php
if(!empty($_FILES))
    $upload_image = array('1','2','3','4','5');
    foreach($upload_image as $i) {
    if(!empty($_FILES["hotel_img$i"]['name']))
    {
        $hotel_ID= 12;
        $config['file_name'] = $this->session->userdata('user_id').'-'.$hotel_ID.'-'.time().$i;
        $config['upload_path'] =realpath(APPPATH . '../img');
        $config['allowed_types'] = 'gif|jpg|png|jpeg';
        $config['max_size'] = '512';
        $config['max_width'] = '1024';
        $config['max_height'] = '768';
        $config['overwrite'] = TRUE;
        $this->upload->initialize($config);
        $form_name = 'hotel_img' . $i;
        if(!$this->upload->do_upload($form_name))
            {       
                $data['msg'] .= "ERROR";
            }
            else
            {   
                $file_data = $this->upload->data();
                $image_data['img_url'] = $file_data['file_name'];
                $image_data['img_size'] = $file_data['file_size'] * 1024;
                $image_data['img_forID'] = $hotel_ID;
                $this->model_hotels->insert_image($image_data);
                $data['msg'] .= "Uploaded Picture No $i";
                $config_thumb['image_library'] = 'gd2';
                $config_thumb['source_image'] = $file_data['full_path'];
                $config_thumb['maintain_ratio'] = FALSE;
                $config_thumb['width'] = 250;
                $config_thumb['height'] = 150;
                $config_thumb['new_image'] = realpath(APPPATH . '../img').'/thumb/thumb_' .  $file_data['file_name'];
                $this->load->library('image_lib', $config_thumb);
                $this->image_lib->resize();
                $this->image_lib->clear(); 
            }
        }
    }
    $this->model_hotels->set_hotel_thumb($hotel_ID);
}   ?>
  • 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-13T01:35:54+00:00Added an answer on June 13, 2026 at 1:35 am

    try adding this to your config:

    $config['create_thumb'] 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I took many hours trying to solve this problem I have attempted, without success.
I have a very strange problem, which took already several hours of my attention:
I have problem SIMILAR to preventing form data reposting, but not quite the same
I encountered a problem that took me too much time, but without resolving it.soI
I have a problem on a tableview with section by date. I took the
So I have sent close to two hours searching for an answer but nothing
I have this problem, but in SAS. To use the example provided in this
It took me hours to finally get the format right on all browsers but
I have a problem here. I want to query my MongoDB in my Node
I have problem with http://abfoodpolicy.com/ . In IE 8 and 9 the right sidebar

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.