how to do dynamic file limit on CMultiFileUpload?

Hi there,

I created the file upload with CMultiFileUpload. I want to create dynamic file limit when the user delete the uploaded file and temp uploaded file. How can I do it?

this is my view code


<div class="row" id="file_upload">

    <?php

		$maxcnt = 5;

		if ($fixedassets->file_name)

		{ 

			

			$obj = json_decode($fixedassets->file_name,true); 

			foreach($obj as $k => $v)

			{	

				$file = '/images/fixedassets/'. $fixedassets->id . '/'. $v;	

				echo '<div id="forAjaxRefresh_'. $maxcnt .'">';

				echo '<img src="http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . $file.'" /><br />';

				echo CHtml::link('remove', array('view', 'id'=>$fixedassets->id, 'img'=>$v));

				//echo CHtml::ajaxLink('remove', array('delimg', 'id'=>$fixedassets->id, 'img'=>$v), array('update'=>'#forAjaxRefresh_' . $maxcnt));

				echo '</div>';

				$maxcnt--;

			}

			

		} 

		

		echo $form->labelEx($fixedassets,'file_name');

		//echo $this->renderPartial('cmultifileupload_widget', array('model'=>$fixedassets));

		$this->widget('CMultiFileUpload', array(

			 'model'=>$fixedassets,

			 'name'=>'file_name',

			 'id'=>'file_name',

			 'attribute'=>'file_name',

			 'accept'=>'jpg|gif|png|pdf',

			 'options'=>array(

				//'onFileSelect'=>'function(e, v, m){ alert("onFileSelect - "+v) }',

				//'afterFileSelect'=>'function(e, v, m){ alert("afterFileSelect - "+v) }',

				//'onFileAppend'=>'function(e, v, m){ alert("onFileAppend - "+v) }',

				//'afterFileAppend'=>'function(e, v, m){ alert("afterFileAppend - "+v) }',

				//'onFileRemove'=>'function(e, v, m){ alert("onFileRemove - "+v) }',

				'onFileRemove'=>'function(e, v, m){if(confirm("File Remove - "+v)==true){return true;}else{return false;}}',

				//'afterFileRemove'=>'function(e, v, m){ alert("Removed - "+v) }',

				'max'=>$maxcnt,

				//jQuery("#Fixedassets_file_name").MultiFile(4)

			 ),

		  ));

		echo  '<span style="color:red;">File type must be : jpg, gif, png, pdf</span><br />';

		echo $form->error($fixedassets,'file_name');	

		?>

	</div>		

Regards

T