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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:02:26+00:00 2026-06-01T14:02:26+00:00

I have an image upload function that supports multiple files upload, but somehow it

  • 0

I have an image upload function that supports multiple files upload, but somehow it only uploads five images at once at most.

I really need it working with like maybe a hundred pictures to upload at once.

Here’s the PHP file that handles upload:

session_start();
$path = $_SERVER['DOCUMENT_ROOT'];

// Include the Image class file and database for the database connection
include_once $path . "/includes/db.php";
include_once $path . "/classes/Image.php";
$folderName = $_SESSION['id'];

// Loop through the image array
for ($i = 0; $i < count($_FILES['upload']); $i++) {
    // Creating image location information
    $fileLink = "upload/$folderName/" . $_FILES['upload']['name'][$i];
    $fileType = $_FILES['upload']['type'][$i];
    $fileSize = ($_FILES['upload']['type'][$i]) / 1024;

    // See if a photo uploads to just upload not to a specific user
    $source = "$path/$fileLink";
    $insertImageQuery = "INSERT INTO Image (id, image_link, image_type, image_size) VALUES($folderName, '$fileLink', '$fileType', '$fileSize')";
    if ((move_uploaded_file($_FILES["upload"]["tmp_name"][$i], $source)) && mysql_query($insertImageQuery)) {

        // Create a new image object after a file moves to a location
        $curImage = new Image();
        $curImage -> scaleFunction($source);
        $curImage -> save($source);
    }
}

And here’s the Image class:

<?php
    $path = $_SERVER['DOCUMENT_ROOT'];
    require_once ($path . "/includes/constants.php");

    class Image {
        private $image;

        //Private Variable stores image type information
        private $image_type;
        // It creates a PHP picture "resource" from imagecreate
        // calls, and this allows for special function calls
        // like imagesy and imagesx.

    function load($filename) {
        $image_info = getimagesize($filename);
        $this -> image_type = $image_info[2];
        if ($this -> image_type == IMAGETYPE_JPEG) {
            //Create JPEG file from source
            $this -> image = imagecreatefromjpeg($filename);
        } elseif ($this -> image_type == IMAGETYPE_GIF) {
            //Create GIF file from source
            $this -> image = imagecreatefromgif($filename);
        } elseif ($this -> image_type == IMAGETYPE_PNG) {
            //Create PNG file from source
            $this -> image = imagecreatefrompng($filename);
        }
    }

    function getWidth() {
        // Use a built-in PHP function to get width in pixels
        return imagesx($this -> image);
    }

    function getHeight() {
        // Use a built-in PHP function to get height in pixels
        return imagesy($this -> image);
    }

    function resizeToHeight($height) {

        $ratio = $height / $this -> getHeight();
        $width = $this -> getWidth() * $ratio;
        $this -> resize($width, $height);
    }

    function resizeToWidth($width) {
        $ratio = $width / $this -> getWidth();
        $height = $this -> getHeight() * $ratio;
        $this -> resize($width, $height);
    }

    // Scale to a particular percentage, for future use
    function scale($scale) {
        $width = $this -> getWidth() * $scale / 100;
        $height = $this -> getheight() * $scale / 100;
        $this -> resize($width, $height);
    }

    function resize($width, $height) {
        $new_image = imagecreatetruecolor($width, $height);
        imagecopyresampled($new_image, $this -> image, 0, 0, 0, 0,
                           $width, $height, $this -> getWidth(),
                           $this -> getHeight());
        $this -> image = $new_image;
    }

    // Save a picture with a given quality (compression), with
    // 100 being the highest quality.
    // It is only used for JPEG files because the
    function save($filename, $image_type = IMAGETYPE_JPEG, $compression = 100) {

        if ($image_type == IMAGETYPE_JPEG) {
            imagejpeg($this -> image, $filename, $compression);
        } elseif ($image_type == IMAGETYPE_GIF) {

            imagegif($this -> image, $filename);
        } elseif ($image_type == IMAGETYPE_PNG) {

            imagepng($this -> image, $filename);
        }
    }

    function output($image_type = IMAGETYPE_JPEG) {

        if ($image_type == IMAGETYPE_JPEG) {

            imagejpeg($this -> image);
        } elseif ($image_type == IMAGETYPE_GIF) {

            imagegif($this -> image);
        } elseif ($image_type == IMAGETYPE_PNG) {

            imagepng($this -> image);
        }
    }

    function scaleFunction($filename) {
        $this -> load($filename);
        if ($this -> getHeight() > IMAGE_THRESHOLD) {
            $this -> resizeToHeight(IMAGE_THRESHOLD);
        }
        if ($this -> getWidth() > IMAGE_THRESHOLD) {
            $this -> resizeToWidth(IMAGE_THRESHOLD);
        }
    }

    } // End of the image class
?>

Okay, so this is what I have for php.ini

max_execution_time = 120
max_input_time = 120
; Whether to allow HTTP file uploads.
file_uploads = On
; Maximum amount of memory a script may consume (50MB)
memory_limit = 50M
; Maximum size of POST data that PHP will accept.
post_max_size = 30M
; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

But it still doesn’t seem to work with more than five images. The article I found said to restart the server. But my website is hosted on GoDaddy. Any idea?

Also, here’s my form that handle file submission

    <form action="/functions/processor.php" method="post" enctype="multipart/form-data">
        <input class="upload choose_file" type="file" name="upload[]" multiple/>
        <button class="upload" type="submit">
            Upload
        </button>
    </form>
  • 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-01T14:02:27+00:00Added an answer on June 1, 2026 at 2:02 pm

    If you have access to php.ini, try setting the max_file_uploads setting. GoDaddy may have lowered it and you can adjust it in php.ini

    max-file-uploads


    Never mind, I think I got it.

    count($_FILES['upload'])
    

    is wrong. Do

    count($_FILES['upload']['name'])
    

    $_FILES['upload'] always has five elements: name, tmp_name, size, type, and error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript function that will show the image you're about to upload
I have a function in PHP that resizes images into a thumbnail, my image
I have an application that uses the Paperclip plugin for image upload. Now that
I have a form that, among other things, accepts an image for upload and
I have an image upload script, and the thumbnails that its producing are posterized
Ok, I have an in template function that get's submitted via method=POST. But I
This is a basic image upload script, that when a user uploads a file
Scenario I have a Node.JS service (written using ExpressJS ) that accepts image uploads
I have a PHP function that I use regularly for working with images (resizing,
I need to upload multiple images via form. I thought that I will do

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.