1
votes

I have a website hosted on a PC I have no access to. I have an upload form allowing people to upload files up to 30MB big. My server side script is done in PHP..then how can i set size limit in php ?

5
you can check size of file. If it is more than 30MB, do not upload itKhushboo
you must change in php.ini fileArun

5 Answers

1
votes

You can use this for limiting your file size..

ini_set("post_max_size", "30M");
ini_set("upload_max_filesize", "30M");
ini_set("memory_limit", "20000M"); 
0
votes

Getting File Size in PHP is done in the following way

$filesize = $_FILES['file']['size'];

Here you can get the file size and can check for the size to be limited to

if($filesize<yourmaxsize)
{
    //do something
}

If you want file size of 30MB to be uploadable then There is some thing called as maximum size that can be uploaded generally it will be 2MB i think you can go to php.ini (configuration file) and change its size to 30MB or 50MB whatever the size you want

0
votes

in your php configure file which known as php.ini, there is parameter called upload_max_filesize, you can change that value to what you want. that will be affected to your all php applications.

0
votes

Try increasing the following values in your php.ini file, for example:

    memory_limit = 99M
    max_execution_time = 300
    upload_max_filesize = 30M
    post_max_size = 24M
-1
votes
if(isset($_FILES['uploaded_file'])) {

    $maxsize = 2097152;

    if(($_FILES['uploaded_file']['size'] >= $maxsize) || ($_FILES["uploaded_file"])) { 
       //alert for large size
    }
}