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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:08:50+00:00 2026-06-02T21:08:50+00:00

I have some script for image upload and I’m using it with form validation.

  • 0

I have some script for image upload and I’m using it with form validation. So this is the code:

$this->form_validation->set_rules('name','Name','required|max_length[30]|xss_clean');
$this->form_validation->set_rules('desc','Description','required|xss_clean');

if ($this->form_validation->run() == TRUE)
{
    $config = array(
        'allowed_types' => 'jpg|jpeg|png|gif',
        'upload_path' => path/to/folder,
        'max_size' => 3000,
        'max_height' => 1024,
        'max_width' => 1024,
        'remove_spaces' => TRUE
    );
    $this->load->library('upload', $config);

    if ($this->upload->do_upload())
    {
        //code for insert this data into database
    }
    else
    {
        //code for FALSE the form validation and error message with flashdata
    }

Now I would like to false form if there is some error with image upload. I want to do this like the error of some field (if it’s empty), to get data of post variables back (for field’s content).

What’s the best way to do that?

  • 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-02T21:08:53+00:00Added an answer on June 2, 2026 at 9:08 pm

    The else condition of the $this->form_validation->run() and $this->upload->do_upload() should be similiar.

    form validation:

    $data['error_message'] = validation_errors();
    $this->load->view('form', $data);
    

    file upload:

    $data['error_message'] = $this->upload->display_errors();
    $this->load->view('form', $data);
    

    The ‘form’ view is the one loaded initially. It can have a div of this sort:

    <div class="error_message">
       <?php if ($error_message) {
          echo $error_message;
       } ?>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script which collects an image, link and some text content from
I have some boiler-plate script required for a Telerik RadGrid on one of my
I have some Perl code that executes a shell script for multiple parameters, to
I have some questions about the performance of this simple python script: import sys,
I am using gmap3 script to show clustering markers, but i have some questions
I have a form that lets users upload a image of them self. I
i have a upload script to upload some files to a directory. every file
Hi I am integrating the watermark code http://koivi.com/php-gd-image-watermark/ This script works well. But I
I have an multiple image upload script, it resizes images and creates a thumbnail.
I have a simple image upload script that uses SimpleImage.php (http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/) to resize and

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.