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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:37:19+00:00 2026-06-07T05:37:19+00:00

I have a method that checks if a thumbnail is validate for uploading. For

  • 0

I have a method that checks if a thumbnail is validate for uploading. For some reason it is returning false in the calling program.

The image file definitely meets the requirements that I set for it in terms of correct size, dimensions, file type and there are no errors in the file.

This is the print_r() of the Image file:

imageArray ( [file] => Array ( [name] => juliensbook2slide.jpg [type] => image/jpeg [tmp_name] => C:\Users\chris\AppData\Local\Temp\php5A99.tmp [error] => 0 [size] => 20590 ) )

Here is the method code:

public function checkThumb(){
        $this->temp_dir = $_FILES['file']['tmp_name'];
        $this->image_type = $_FILES['file']['type'];
        $this->image_size = $_FILES['file']['size'];
        $this->image_name = $_FILES['file']['name'];
        $this->image_error = $_FILES['file']['error'];
        @$this->image_dimensions = getimagesize($this->temp_dir);
        $this->image_width = $this->image_dimensions[0]; // Image width
        $this->image_height = $this->image_dimensions[1]; // Image height
        $this->path = '';
        $this->error = '';
        if(!empty($this->image_name) && $this->image_error == 0){

            $this->path = 'img/thumb_/'.$this->random_name. $_FILES['file']['name'];

            if(in_array($this->image_type, $this->allowed_type)){

                if($this->image_size <= $this->max_size){

                    if(($this->image_width < $this->max_width) && $this->image_height < $this->max_height){


                        return true;

                    }else{
                        return $error = 'ERROR: Image dimension must be no larger than 4050x4050';
                    }

                }else{
                    return $error = 'ERROR: Image size must be no larger than 5MB';
                }
            }else{
                return $error = 'ERROR: image must be .jpg, .gif, .png only.';
            }
        }else {
            return false;
        }
    }

and here is the code where it is not moving the uploaded image because it is returning false:

if($register->checkThumb){
                //send image to permanent image directory
                $register->moveUploadedImage();

                //if the thumbnail failed validation put the error message in variable
            }else if(is_string($register->checkThumb())){
                $message = $register->checkThumb();

            }
                print_r($_FILES);
                //put record of user into database
                $register->convertSex();
                $register->insertIntoDB($thumb);
}

So why is it returning false?

  • 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-07T05:37:20+00:00Added an answer on June 7, 2026 at 5:37 am

    You weren’t calling the method. There were no round brackets after the method name. So basically you were checking if a property named checkThumb is set.

    As in $register->checkThumb vs. $register->checkThumb().

    This should work:

    if($register->checkThumb()){  //send image to permanent image directory
        $register->moveUploadedImage();
    }  //if the thumbnail failed validation put the error message in variable
    else if(is_string($register->checkThumb())) {
        $message = $register->checkThumb();
    }
    

    But i would recommend not calling the same method 3 times so I’d use the following:

    $checked_thumb = $register->checkThumb();
    if($checked_thumb){  //send image to permanent image directory
        $register->moveUploadedImage();
    }  //if the thumbnail failed validation put the error message in variable
    else if(is_string($checked_thumb)) {
        $message = $checked_thumb;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method that checks some assumptions and either follows the happy path,
I have a method that checks spots in a 2D array, and it also
i currently have a method that checks what is around the centre item in
I have this method that changes an larger image source on click. I need
I have one method that opens a file and passes off to another function
I have a method that checks certain things and returns a Boolean based on
So I have a method that checks for internet connection, but only during the
I have a method that checks all of the combinations of 5 different conditions
So I have a method that checks if the device is connected to the
I have tried to fix a method that checks if the user has Skype

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.