Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get max file upload in bytes?

Tags:

php

I'm using ini_get('upload_max_filesize') to get the max file upload size.
The result is 5M.

What is the easiest way to get this in bytes?

like image 322
Steven Avatar asked Nov 14 '10 12:11

Steven


People also ask

How do I increase max upload file size?

Using Plugin MethodGo to your WordPress Dashboard → Plugins → Add new, search “Increase Max Upload Filesize”, then Install and Activate the plugin. Once installed, go to plugin settings and simply enter the value for upload size. Click the Save Changes button to apply the new upload size.

What is the maximum size of file uploading?

The maximum file size limit for uploads to Box varies depending on your account type: Free personal: 250 MB. Starter: 2 GB. Business: 5 GB.

How can I increase maximum upload file size in cPanel?

Open the MultiPHP INI editor and select a location from the dropdown. Scroll to the entry for upload_max_filesize and edit the associated value. Ensure that the value for post_max_size is larger than upload_max_filesize, and click apply at the bottom of the page.


1 Answers

You could use the return_bytes from the documentation:

function return_bytes($val) {
    $val = trim($val);
    $last = strtolower($val[strlen($val)-1]);
    switch($last) {
        // The 'G' modifier is available since PHP 5.1.0
        case 'g':
            $val *= (1024 * 1024 * 1024); //1073741824
            break;
        case 'm':
            $val *= (1024 * 1024); //1048576
            break;
        case 'k':
            $val *= 1024;
            break;
    }

    return $val;
}

return_bytes(ini_get('post_max_size'));
like image 84
Darin Dimitrov Avatar answered Oct 31 '22 17:10

Darin Dimitrov