get upload max file size in kb in php

You can retrieve the maximum allowed file size for uploads in kilobytes using the ini_get function in PHP. The upload_max_filesize directive sets the maximum size of an uploaded file. Here's an example code snippet:

main.php
$max_upload = (int)(ini_get('upload_max_filesize'));
$max_post = (int)(ini_get('post_max_size'));
$max_size = min($max_upload, $max_post) * 1024; // size in kilobytes
echo "Maximum upload file size: " . $max_size . " KB";
222 chars
5 lines

In this example, we get the values of upload_max_filesize and post_max_size using the ini_get function. We then convert both values to integers and take the minimum value. We multiply that by 1024 to get the maximum size in kilobytes. Finally, we output the result using the echo statement.

Note that this is just an example and you may need to adjust the code to fit your specific needs.

gistlibby LogSnag