How to determine the max file upload limit in php -


How can the file upload size be allowed through a PHP script?

<; uploads are limited by three options: upload_max_filesize , post_max_size and memory_limit

. Your upload is only made if it is not expected from one of them.

The ini_get () function gives you a small hand of the limit and should be changed first. Thx for this

  function return_bytes ($ val) {$ val = trim ($ val); $ End = strawler ($ well [strollon ($ val) -1]); Switch ($ last) {case 'g': $ well * = 1024; Case 'm': $ val * = 1024; Case 'of': $ val * = 1024; } Return $ val; } Function max_file_upload_in_bytes () {// select maximum upload size max_upload = return_bytes (ini_get ('upload_max_filesize')); // select the post limit max_post = return_bytes (ini_get ('post_max_size')); // Select Memory Limit memory_limit = return_bytes (ini_get ('memory_limit')); // The smallest withdrawal of these, it defines the actual border return minute ($ max_upload, $ max_post, $ memory_limit); }  

Source:


Comments