Wednesday, March 14, 2012

PHP script, to get maximum upload file size variable from php.ini



 PHP maximum upload file size is determined by three variables in php.ini
 ; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 128M
 ; Maximum size of POST data that PHP will accept.
; http://php.net/post-max-size
post_max_size = 100M
;Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
 upload_max_filesize = 100M

To access these variables in PHP script:
$max_upload = (int)(ini_get('upload_max_filesize'));
$max_post = (int)(ini_get('post_max_size'));
$memory_limit = (int)(ini_get('memory_limit'));
$upload_mb = min($max_upload, $max_post, $memory_limit);


  Here $upload_mb is the minimum of these three variables, i.e the maximum file size you can upload.

Note: some directories you may need to modify in php.ini
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
; extension_dir = "ext"
extension_dir = "C:\php\ext"

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://php.net/upload-tmp-dir
;upload_tmp_dir =
upload_tmp_dir ="C:\LMS\file_uploads"

;session.save_path defines the argument which is passed to the save handler. If you choose the ;default files handler, this is the path where the files are created.
session.save_path="C:\LMS\file_uploads"

No comments:

Post a Comment