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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:37:02+00:00 2026-05-21T04:37:02+00:00

I have had issues trying to get my images to upload correctly, I have

  • 0

I have had issues trying to get my images to upload correctly, I have a feeling its a basic error. The issue is that it does not seem to upload the image:

addimage.php

<?php

include('includes/session.php');

include('includes/header.php');

include('includes/class/class.form.php');

include('includes/class/class.image.php');

define("MAX_SIZE","1000000");

$formImageUpload = new Form('addimage.php', 'imageUpload', 'post','multipart/form-data', ''); //return CheckImage();

$Message = "";


if(isset($_POST["submit"])) {

    $formImageUpload->setStickyData($_POST);

    $formImageUpload->checkUpload("ImagePath","image/jpeg", MAX_SIZE);


    $formImageUpload->checkNotEmpty("ImageName");


    if($formImageUpload->getValid() == true){

        $AddImage = new Image();

        $AddImage->setImageName($_POST["ImageName"]);

        $AddImage->setImagePath($_POST["ImagePath"]);

        $AddImage->imageUpload();

        $AddImage->saveImage();

        $Message = "Thank You, Your Image Has Been Uploaded";

        print_r($_FILES);

        exit;

    } else {

        $Message = "Sorry You Have An Error Please Try Again";
    }

}

$formImageUpload->openFieldset();
$formImageUpload->makeInputBox('Image','ImageName','');
$formImageUpload->makeHiddenField("MAX_FILE_SIZE", MAX_SIZE);
$formImageUpload->makeUpLoadBox('Image Path',"ImagePath",'');
$formImageUpload->makeSubmitButton("submit","Image Upload");
$formImageUpload->closeFieldset();
?>

 <section class="left">

<h1  class="Heading">Add Image</h1>

    <p class="loginError"><?php echo $Message;?></p>

<?php echo $formImageUpload->getHTML(); ?>

</section> <!-- Section Left End -->

<section class="right">
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
    Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
    It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </p>
</section><!-- Section Right End -->



<?php
include('includes/footer.php');
?>

imageclass.php

<?php

require_once('./includes/database.php');

class Image{

    private $iID;

    private $sImageName;

    private $sImagePath;

    public function loadImage($iID){

        global $database;

        $Query = "SELECT * FROM Gallery WHERE id =" .$iID;

        $resResult = $database->query($Query);

        //Fetch The Row

        $aImage = $database->fetch_array($resResult);

        $this->iID = $aImage["id"];
        $this->sImageName = $aImage["imageName"];
        $this->sImagePath = $aImage["imagePath"]; 

        $this->bExisting = true;

}

public function saveImage(){

    global $database;

    if($this->bExisting == false){

        $Query = "INSERT INTO Gallery(imageName,imagePath) VALUES ('". $database->escape_value($this->sImageName)."','".$database->escape_value($this->sImagePath)."')";

        $bResult = $database->query($Query);

        if($bResult){

            $this->iID = $database->get_last_insert_id();

            $this->bExisting = true;

        } else {

            die("Save Failed");
        }

    }
}

public function removeImage($image_id = NULL){

    // if there is no ID Exit

    if(!$image_id) return;

    global $database;

    $image_id = $database->escape_value($image_id);

    $this->loadImage($image_id);

    $database->query("DELETE FROM Gallery WHERE id = $image_id");

    if(is_file($this->image_path . $this->setImagePath)) unlink($this->image_path . $this->setImagePath);

    //Unsets Image var

    $this->_unsetImage();


}

function _unsetImage() {

    $this->iID = NULL;
    $this->sImageName = NULL;
    $this->sImagePath = NULL; 
    $this->bExisting = FALSE;

}




            // Get Functions

public function getImageID(){
        return $this->iID;
}    

public function getImageName(){
        return $this->sImageName;
}

public function getImagePath(){
        return $this->sImagePath;
}

// Set Functions

public function setImageID($iID){

    global $database;

    $iID = $database->escape_value($iID);

    $this->iID = $iID;
}    


public function setImageName($sImageName){

    global $database;

    $sImageName = $database->escape_value($sImageName);

    $this->sImageName = $sImageName;
}   

public function setImagePath($sImagePath){

    global $database;

    $sImagePath = $database->escape_value($sImagePath);

    $this->sImagePath = $sImagePath;
}


public function imageUpload($file){

    $this->bExisting = false;

    $location = base_url()."includes/images/Gallery/";

    $target = $_FILES['ImagePath']['name']; 

    $target = move_uploaded_file($_FILES ['ImagePath']['tmp_name'], $location.$target);
}



}

?>
  • 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-05-21T04:37:02+00:00Added an answer on May 21, 2026 at 4:37 am

    Try to do a test where you just:
    var_dump($_FILES)
    This is the global array that contains all uploaded files. If this is empty, check:

    1. Permissions on the temporary directory
    2. If file upload are allowed
    3. If your form element looks (a bit) like <form enctype="multipart/form-data">
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Fedora and I have had some issues to get javac to work
I am having trouble with the following SQL statement. I have had this issue
This is very odd. I have never had this issue with ShowDialog in C#.
I have been working on a json decode issue (which I have already had
I have just migrated to mysql 5.5.20 and I had a performance issue with
I have a follow-up question regarding an issue I previously had on SO here
I think my question is pretty basic. I was trying to get Open CV
I've been trying to get this to work. It's basically a way to have
I have an issue where I am trying to order a result set by
I've been having trouble trying to get PIL to nicely downsample images. The goal,

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.