Restricting Image Upload Size and Upload Time Using PHP

How to Limit File Upload Size using PHP ?

For reducing high bandwidth usage network admins can limit file size  to be uploaded  on server by other users. Following script limits file size a user can upload:

<?php
if ($_FILES[“file”][“size”] < 25000)) // Max File Size: 25KB
{
echo “File size exceeds maximum.”;
}
?>

How to Limit File Upload Time Using PHP ?

Other trick for network admins for reducing high bandwidth usage is to limit file upload time. For this you may edit server’s php.ini file or you can set upload time in your site:

ini_set(‘max_input_time’, 300);

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.