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

  • Home
  • SEARCH
  • 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 8116555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:52:22+00:00 2026-06-06T03:52:22+00:00

I am using an upload script that is working great: ini_set(‘memory_limit’, ‘256M’); function uploadImage($files_name,

  • 0

I am using an upload script that is working great:

ini_set('memory_limit', '256M');

function uploadImage($files_name, $files_tmp_name, $files_error, $files_type, $uploaded_photos_array, $image_type, $replace_position='69') { //Checks if the file uploaded correctly, saves the folder name to the DB, and calls the resizeAndPlaceFile 3 times     
    global $address;

    //If the directory doesn't exist, create it
    if (!is_dir('../images/uploads/temp/'.$address)) {
        mkdir('../images/uploads/temp/'.$address);
    }

    $myFile_original = $files_name; //Store the filename into a variable

    //Change the filename so it is unique and doesn't contain any spaces and is all lowercase
    $myFile = str_replace(' ', '_', $myFile_original); //change all spaces to underscores within a file name
    $myFile = strtolower($myFile); //Make all characters lowercase
    //$anyNum = rand(20,500789000); //Generate a random number between 20 and 500789000  
    //$newFileName = $anyNum.'_'.$myFile; //Combine the random number with the filename to create a unique filename
    $newFileName = $myFile;

    $info = pathinfo($newFileName); //Finds the extension of the filename
    $directory_name =  basename($newFileName,'.'.$info['extension']); //Removes the extension from the filename to use as the name of the directory

    $folder = '../images/uploads/temp/'.$address.'/'.$directory_name.'/'; //Folder to upload to

    //If the directory doesn't exist, create it
    if (!is_dir($folder)) {
        mkdir($folder);
    }


    //===Check if the File already exists======== 
    if (file_exists($folder.'large.jpg')) {
        echo $myFile_original." already exists.";
    } //******If file already exists in your Folder, It will return zero and Will not take any action===

    else { //======Otherwise File will be stored in your given directory and Will store its name in Database===


        //copy($_FILES['fileField']['tmp_name'],$folder.$newFileName); //===Copy File Into your given Directory,copy(Source,Destination)


        // Check if file was uploaded ok
        if(!is_uploaded_file($files_tmp_name) || $files_error !== UPLOAD_ERR_OK) {
            exit('There was a problem uploading the file. Please try again.');
        } else {
            /*
            $sql = 'INSERT into tblfileupload SET
                                file_name = "'.$folder.'"'; 
                        $result = $conn->query($sql) or die($conn->error);

                        if($result > 0) { //====$res will be greater than 0 only when File is uploaded Successfully====:)
                            echo 'You have Successfully Uploaded File';
                        }
            */


            if(!function_exists('resizeAndPlaceFile')){
                function resizeAndPlaceFile($image_size, $files_tmp_name, $files_type, $folder) { //Resizes the uploaded file into different sizes

                    //echo '<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />The resizeAndPlaceFile function is being called!';

                    // Create image from file
                    switch(strtolower($files_type)) {
                        case 'image/jpeg':
                            $image = imagecreatefromjpeg($files_tmp_name);
                            break;
                        case 'image/png':
                            $image = imagecreatefrompng($files_tmp_name);
                            break;
                        case 'image/gif':
                            $image = imagecreatefromgif($files_tmp_name);
                            break;
                        default:
                            exit('Unsupported type: '.$files_type);
                    }

                    // Get current dimensions
                    $old_width  = imagesx($image);
                    $old_height = imagesy($image);

                    // Target dimensions for large version
                    switch($image_size) {
                        case 'large':
                            $max_width = '600'; //Large Photo (Listing Page)
                            break;
                        case 'medium':
                            $max_width = '157'; //Medium Photo (Dashboard)
                            break;
                        case 'thumbnail':
                            $max_width = '79'; //Small Photo (Listing Page - Thumbnail)
                            break;
                    }

                    if($max_width > $old_width) {
                        $max_width = $old_width;
                    }

                    $max_height = ($old_height/$old_width)* $max_width;


                    // Get current dimensions
                    $old_width  = imagesx($image);
                    $old_height = imagesy($image);

                    // Calculate the scaling we need to do to fit the image inside our frame
                    $scale = min($max_width/$old_width, $max_height/$old_height);

                    // Get the new dimensions
                    $new_width  = ceil($scale*$old_width);
                    $new_height = ceil($scale*$old_height);


                    // Create new empty image
                    $new = imagecreatetruecolor($new_width, $new_height);

                    // Resize old image into new
                    imagecopyresampled($new, $image, 0, 0, 0, 0, $new_width, $new_height, $old_width, $old_height);

                    //Output the image to a file
                    imagejpeg($new, $folder.$image_size.'.jpg',100);

                    // Destroy resources
                    imagedestroy($image);
                    imagedestroy($new);

                } //end function resizeAndPlaceFile
            } //end if !function_exists['resizeAndPlaceFile']
            resizeAndPlaceFile('large',$files_tmp_name, $files_type, $folder); //Large Photo (List Page)
            resizeAndPlaceFile('medium',$files_tmp_name, $files_type, $folder); //Medium Photo (Dashboard)
            resizeAndPlaceFile('thumbnail',$files_tmp_name, $files_type, $folder); //Small Photo (List Page - Thumbnail)

            if($image_type == 'replace') { //If this is being run for a replace, then replace one of the values instead of adding it to the end of the array
                $uploaded_photos_array[$replace_position] = $folder; //This replaces the value of the old image with the new image
            } else if($image_type == 'initial') { //otherwise, add it to the end of the array
                array_push($uploaded_photos_array,$folder);
            }

            return $uploaded_photos_array;
        } //end else         
    } //end else
} //end function uploadImage

When I try to upload any file above 2.1mb, it won’t upload the file and won’t display any error so I have no idea why it is not working. Why will my upload form not upload files over 2.1mb using php?

  • 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-06T03:52:23+00:00Added an answer on June 6, 2026 at 3:52 am

    Check and change the following php.ini instructions:

    memory_limit = 32M
    upload_max_filesize = 10M
    post_max_size = 20M
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a upload script and using move_uploaded_file() function. The problem is, that
I'm using a JavaScript upload script that says to run the initialize function as
Using this upload script and it was working ok a week ago but when
I am working on an image upload script and ran into this problem. Using
I have a script that uploads an image using JavaScript, as seen here .
I am using the following script to upload pictures to my website. It is
I'm using pycurl to upload a file via put and python cgi script to
I'm using the script below, so user can upload their profile picture. The first
I am trying to upload files via FTP using the following script. The file
I'm writing a script using Perl and Net::FTP, which is trying to upload a

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.