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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:59:35+00:00 2026-06-17T10:59:35+00:00

I tried to create an application wich allows me to upload files larger then

  • 0

I tried to create an application wich allows me to upload files larger then 5 MB but I always get an error that says that the file is to large. I modified php.ini upload_max_filesize and post_max_size and set it to 1GB but it did not work.

This is my code:

if(is_uploaded_file($_FILES['pdf']['tmp_name'])&&($_FILES['pdf']['error'] == UPLOAD_ERR_OK)){
    $file = $_FILES['pdf'];
    $size = round($file['size']/10485760);
    if($size > 10485760){
        echo 'The uploaded file was to large.';
    }

    if(($file['type'] != 'application/pdf') && (substr($file['name'], -4) !='.pdf')){
        echo 'The uploaded file was not a PDF.';
    }

    if(!array_key_exists('pdf', $add_pdf_errors)){
        $tmp_name = sha1($file['name'].uniqid('', TRUE));
        $dest = '../pdfs/'.$tmp_name.'_tmp';

        if(move_uploaded_file($file['tmp_name'], $dest)){
            $_SESSION['pdf']['tmp_name'] = $tmp_name;
            $_SESSION['pdf']['size'] = $size;
            $_SESSION['pdf']['file_name'] = $file['name'];
            echo '<h4>The file has been uploaded!</h4>';
        }else{
            trigger_error('The file coul not be moved.');
            unlink($file['tmp_name']);
        }
    }
}else{
    switch ($_FILES['pdf']['error']){
        case 1:
        case 2:
            echo 'The uploaded file was to large.';
            break;
        case 3:
            echo 'The file was only partially uploaded.';
            break;
        case 6:
        case 7:
        case 8:
            echo 'The file could not be uploaded to a system error.';
            break;
        case 4:
        default:
            echo 'No file was uploaded.';
            break;
    }
}

How can I resolve this problem?

  • 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-17T10:59:36+00:00Added an answer on June 17, 2026 at 10:59 am
    $size = round($file['size']/10485760);
    if($size > 10485760){
        echo 'The uploaded file was to large.';
    }
    

    This logic does not appear to be correct. Comparison is not accurate like that. Try

    $size = $file['size'];
    if($size > 10485760){
        echo 'The uploaded file was to large.';
    }
    

    Also check if ‘The uploaded file was to large.’ is being displayed from within your IF or ELSE part? because both display same message in certain situation, So first we have to find out where does it get displayed

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

Sidebar

Related Questions

I wrote an application that tried to create a default HBaseConfiguration, but when I
I've tried to create a 'tile stamper' application that allows you to select a
I have tried to create a android application that sends a serialzed object from
I tried to create a new Swing GUI desktop application template using NetBean 7.0
I have created an fbml application. I have tried numerous examples of fbjs but
I have tried create this table, but nothing I have tried works from FKs.
I tried to create jar file using command line that I inserted into java
I tried to create FireMonkey application today and added ReportMemoryLeaksOnShutdown to project file to
I am new to Spring and Hibernate. I tried to create a simple application
I want to create an application that can determine if some text was copied

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.