2014-12-15 3 views
1
내가 server.It 잘 작동하지만 지금은 각각의 이미지와 옵션을 삭제 설정할에 파일을 uplaods하는 아약스 로더를 사용 saving.My 현재 이미지처럼 보이게하기 전에 해당 이미지를 삭제할 수 있습니다

:아약스 업 로더를 사용하여 업로드 된 이미지를 삭제합니다

enter image description here

파일 업로드에이 파일 업 로더 스크립트를 사용하고 있습니다. Link

파일 업로드에 대한 나의 코드는 다음과 같습니다

jQuery("#fileuploader").uploadFile({ 
    url:"<?php echo $this->getUrl('pmembers/priority/productimages/') ?>", 
    multiple:true, 
    fileName:"myfile", 
    onSuccess: function (files, response, xhr,pd) { 
     var dir = '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."mkd/uploads/".Mage::getSingleton("customer/session")->getId()."/"; ?>'; 

     jQuery('#files').append('<li style="width:60px; float:left;margin-left:5px; margin-right:5px;"><img width="60" height="60" src="'+dir+files+'" /></li><img src="cross.png" />'); 


     }, 
    }); 
}); 

답변

0

시도 : 이벤트 제거를 클릭 버튼이 서버 연결을 해제 요청 (경로 : "디렉토리 + 파일")을 보내드립니다 클라이언트를 반환합니다 전체 서버 후, 통보.

jQuery를 :

var removeButton = $("li > img:last"); 
removeButton.click(function(){ 
    if (removeButton.attr('handling') != "true") { 
     removeButton.attr('handling', 'true'); 
     var path = removeButton.prev('img[src]').attr('src'); 
     $.ajax({ 
      type: "POST", 
      dataType: "json", 
      url: (url), 
      data: {'path': path}, 
      error: function() { 
       //. Action when error. 
      }, 
      success: function (data) { 
       //. Action when success. 
      } 
     }).done(function(){ 
      removeButton.attr('handling', 'false'); 
     }); 
    } 
}); 

PHP :

$path = $_POST['path']; 
$unlink = unlink($path); 
if (!$unlink) { 
    print json_encode(array("return" => false)); exit(); 
}else { 
    print json_encode(array("return" => true)); exit(); 
} 
+0

메시지에 감사하지만 onclick을 VAR removeButton = jQuery를 ('같은 코드를 사용 일하러하지 않았다 "리 A> IMG을 : 마지막으로");'. 이미지 위에 앵커 태그가 있습니다. Adda

+0

jsfiddle에서 코드를 통과 할 수 있습니까? – lamhieu

관련 문제