In above example, KoolUploader will automatically upload the file once the file is added. To do this, you register handle for OnAddItem event and make the new added item upload.
<?php
require $KoolControlsFolder."/KoolUploader/kooluploader.php";
require $KoolControlsFolder."/KoolAjax/koolajax.php";
$kul = new KoolUploader("kul");
$kul->scriptFolder = $KoolControlsFolder."/KoolUploader";
$kul->handlePage = "handle.php";
$kul->allowedExtension = "gif,jpg,txt,doc,pdf";
$kul->styleFolder=$KoolControlsFolder."/KoolUploader/styles/default";
$kul->progressTracking = true;
$kul->maxFileSize = 512*1024; //500KB
?>
<form id="form1" method="post">
<?php echo $koolajax->Render();?>
<style type="text/css">
.defaultKUL .kulUploadAll
{
display:none;
}
</style>
<?php echo $kul->Render();?>
<script type="text/javascript">
kul.registerEvent("OnAddItem",function(sender,arg){
var _item = kul.getItem(arg.ItemId);
_item.upload();
});
</script>
<div style="padding-top:20px;">
<i>*Note:</i> Please test uploading with *.txt, *.doc, *.pdf, *.jpg, *.gif ( size < 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();
?>