I want to upload file size 15mb


How can i check if the uploaded file size is not greater than 15mb?

Thank you in advance:)

Good morning,

You need to set the upload_max_filesize and post_max_size directives in your php.ini to the same values, anything above 15.

Depends on your host and if you have access to change the php.ini settings.

Kind regards,


yes, I already change to this size 40M,so it means max uploaded size is 40mb am i right?, so in my server script this is how i checked

 if($_FILES['file']['size']  > ){



this is where is stock,how do i compare so that i can limit only to 15mb file size.

Thank you in advance.:slight_smile:

I usually create a constant variable called MAX_FILE_SIZE and set it’s value equal to the maximum file size allowed (in Bytes) and then compare $_FILES[‘file’][‘size’] against the constant and see whether or not it is greater in size than the constant.

For example, you could change your code to this:

define("MAX_FILE_SIZE", 41943040);

if($_FILES['file']['size'] > MAX_FILE_SIZE)
       //file too large in size, send them back to form or something else
      //file size ok, proceed with form process.

You could always add a hidden field to your form containing that value.

Kind regards,


Hi can i aks how did you get this 41943040 ?

Thank you in advance.

Good evening,

That is the equivalent to 40M in Bytes.

This is how I came to that conclusion :slight_smile:


Kind regards,


Thank you :slight_smile: