下面是显示删除消息的代码,但它在每一行中都显示它,这是不正确的,它应该打开;y 显示在文件被删除的行中:
var counter = 0;
function stopImageUpload(success, imagefilename){
var result = '';
counter++;
if (success == 1){
result = '<span class="imagemsg'+counter+'">The file was uploaded successfully!</span><br/><br/>';
$('.listImage').eq(window.lastUploadImageIndex).append('<div>' + htmlEncode(imagefilename) + '<button type="button" class="deletefileimage" image_file_name="' + imagefilename + '">Remove</button><br/><hr/></div>');
}
else {
result = '<span class="imageemsg">There was an error during file upload!</span><br/><br/>';
}
$(".deletefileimage").on("click", function(event) {
var image_file_name = $(this).attr('image_file_name');
jQuery.ajax("deleteimage.php?imagefilename=" + image_file_name)
.done(function(data) {
$(".imagemsg" + counter).html(data);
});
$(this).parent().remove();
});
return true;
}
结果变量在 imageupload.php 中被调用:
打回来:
<script language="javascript" type="text/javascript">window.top.stopImageUpload(<?php echo $result ? 'true' : 'false'; ?>, '<?php echo $_FILES['fileImage']['name'] ?>');</script>
这里是应用程序的链接。
请执行此操作,单击“添加”按钮两次,在两行中使用文件输入上传图像。在这两行中,它都会说明文件上传成功,并且会在各自行的底部显示两个文件的名称。现在通过单击删除按钮删除文件,您将看到消息(文件已删除)显示在两行中,它应该只显示在删除文件的行中