delete multiple image in preview method

hiii friends…

   am very tried to execute this getting preview and delete method  also.... but in delete function i don't know how to get the image name...

<div class="row float">
		<div style="">
			<!--<input type ="file" name="UserDetails[image][]" id="UserDetails_image" multiple />-->
          <?php echo $form->fileField($model ,'image',array(
		<div id="list"></div>
	    <div id="error"></div>
	    <div id="maximage"></div>

script code…

function previewGallery(id) {

var files = document.getElementById(id).files; //id will be assigned into variable.

    for(var i=0;i<files.length;i++){	

    	var del = files[i].name;

    	var image = files[i].name.split('.');	

    	if(image != null || image != ''){

		if((image[1] != "jpg") && (image[1] != "JPG") &&

		  (image[1] != "png") && (image[1] != "PNG") &&

	      (image[1] != "jpeg") && (image[1] != "JPEG")){

		      	$("#error").html('Wrong image format');	


				return false;





			for(var i=0,f; f=files[i]; i++){




			var reader = new FileReader();			

			reader.onload = (function(theFile){			

				return function(e){

				var span = document.createElement('span');				

				span.innerHTML = ['<img style="width:150px;height:150px;" id="previewimg" src="',,'"title="',escape(,'" onclick="deleteimg(this);"> &nbsp;&nbsp;'].join('');

					document.getElementById("list").insertBefore(span, null);																








function deleteimg(img){

	if (confirm('Are you sure to delete ?')) {

	$(img).parent().remove();		//remove the selected image





 plz help me frdz...


use cgridview and costomize CButtonColumn for delete Images