Link to home
Start Free TrialLog in
Avatar of msiedle
msiedle

asked on

Detect Max File size available

Hi all

Is there a way to use PHP to detect the max file size available for file uploads on the server, as apposed to me setting it manually only to find that large uploads get cut off at a certain size?

Eg. I just want to run something like this:

$file_size = get_server_maxfilesize();

Thanks
Mark
Avatar of Khanh Doan
Khanh Doan
Flag of United States of America image

you can run phpinfo();
and then find : upload_max_filesize

Bonmat86.
Avatar of msiedle
msiedle

ASKER

Yea but i don't want to set it manually in code ...I want my script to be smart enough to be able to detect it depending on what server it's on ...is that possible?

I know you can do:
ini_get( 'upload_max_filesize' )

...but that returns a value like '2M' (meaning 2 Meg) ...I'd need a value returned in full byte form. ie. 2097152

Any ideas?

Cheers,
Mark

ASKER CERTIFIED SOLUTION
Avatar of Khanh Doan
Khanh Doan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of msiedle

ASKER

Beautiful ...works great! Thank you :-))

Mark