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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:54:15+00:00 2026-06-03T10:54:15+00:00

Please see the snippet below. I am using it in a way to restrict

  • 0

Please see the snippet below. I am using it in a way to restrict files over 5 mb. Whenever the file is above 5 mb it says that “The file you attempted to upload is not allowed” when in fact it should say “The file you attempted to upload is too large.” It’s not that i placed them in the wrong part of the code, i am using:

if(filesize($_FILES['filename']['tmp_name']) > $max_filesize)

Entire code:

// Configuration - Your Options
$allowed_filetypes = array('.pdf','.jpg','.png','.gif'); 
$max_filesize = 5242880; // Maximum filesize in BYTES (currently 0.5MB).
$upload_path = "/store/user/$user"; 
$filename = $_FILES['filename']['name']; 
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); 
if(!in_array($ext,$allowed_filetypes))
die('The file you attempted to upload is not allowed.');
// Now check the filesize, if it is too large then DIE and inform the user.
if(filesize($_FILES['filename']['tmp_name']) > $max_filesize)
die('The file you attempted to upload is too large.');
// Check if we can upload to the specified path, if not DIE and inform the user.
if(!is_writable($upload_path))
die('');
  • 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-03T10:54:18+00:00Added an answer on June 3, 2026 at 10:54 am

    Your filename extension code is not right, most likely.

    Try with:

    $allowed_filetypes = array('pdf', 'jpg', 'png', 'gif');
    // ...
    $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
    // ...
    

    Otherwise, the file is basically not uploaded due to filesize constraints; you can check this by looking at $_FILES['filename']['error']. The value should be 0.

    If it’s not 0, you can check here what it means: http://www.php.net/manual/en/features.file-upload.errors.php

    In your case, the file is probably too big; check here what could be wrong: http://www.php.net/manual/en/features.file-upload.common-pitfalls.php

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

Sidebar

Related Questions

Please see the code below: #include <iostream> #include <stdlib.h> #include <time.h> using namespace std;
Please see the snippet below and tell me how can I achieve the same
Please see my current html snippet is as below. I am trying to make
I have a DataGridView inside a ContextMenu control, please see the code snippet below:
To understand what I mean, please see this snippet: <table style=width: 100%> <tbody><tr><td> <div
Please see the sample xml given below. As per a requirement, I need to
PLEASE SEE THE EDIT BELOW, THE REPORT SEEMS TO USE CACHED DATA? I cant
Please see below code snippt: <?php //Sets the update and indicator elements by DOM
i have a javascript module name SceneModule, see the code snippet below var SceneModule
I'm trying to create a dynamic ItemizedOverylay (please see the code below) on Google

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.