KoolUploader supports setting max filesize that allow to upload. In above example, the max file size of KoolUploader is set to 500KB, which mean user will not able to upload a file with size more than 500KB.
To set this, you need to put size in byte to maxFileSize property.
*Note: The maxFileSize is only effective in max upload limitation of PHP . Setting maxFileSize to 100MB does not mean that you can upload 100MB. The max file size also depends on following setting of PHP:
- max_execution_time: If the uploading time is over max_execution_time, the page not found error may happen.
- max_input_time : Limit the input upload time
- post_max_size : Limit the max of form post.
- upload_max_filesize : Directly limit the max file size of uploading
<?php
require $KoolControlsFolder."/KoolUploader/kooluploader.php";
require $KoolControlsFolder."/KoolAjax/koolajax.php";
$kul = new KoolUploader("kul");
$kul->scriptFolder = $KoolControlsFolder."/KoolUploader";
$kul->handlePage = "handle.php";
$kul->styleFolder=$KoolControlsFolder."/KoolUploader/styles/default";
$kul->allowedExtension = "gif,jpg,doc,pdf,txt";
$kul->progressTracking = true;
$kul->maxFileSize = 512*1024; //500KB
?>
<form id="form1" method="post">
<?php echo $koolajax->Render();?>
<?php echo $kul->Render();?>
<div style="padding-top:20px;">
<i>*Note:</i> Please test uploading with *.txt, *.doc, *.pdf, *.jpg, *.gif
</div>
<div style="padding-top:5px;">
<i>*Note:</i> The above uploader is set max filesize to 500KB
</div>
</form>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
$KoolControlsFolder = "../../../../KoolControls";
require $KoolControlsFolder."/KoolUploader/kooluploader.php";
//Create handle object and edit upload settings.
$kulhandle = new KoolUploadHandler();
$kulhandle->targetFolder = "../../Temp";
$kulhandle->allowedExtension = "gif,jpg,doc,pdf,txt";
//Call the handle function to handle the request from client
echo $kulhandle->handleUpload();
?>