单击按钮时如何取消文件上载

时间:2012-04-15 13:10:31

标签: javascript jquery

我有一个包含文件输入,上传按钮和取消按钮的表单:

<form action='imageupload.php' method='post' 
 enctype='multipart/form-data' target='upload_target' 
 onsubmit='stopImageUpload(this);' class='imageuploadform' >
   <p class='imagef1_upload_form' align='center'>
      <label>Image File: 
        <input name='fileImage' type='file' class='fileImage' />
      </label>
      <input type='submit' name='submitImageBtn' class='sbtnimage' value='Upload' />   
      </label>
   </p>
   <p class='imagef1_cancel' align='center'>
     <label>
       <input type='button' name='imageCancel' class='imageCancel' value='Cancel' />
     </label>
   </p> 
   <iframe class='upload_target' name='upload_target' src='#' style='width:0;height:0;border:0px;solid;#fff;'>
   </iframe>
</form>

我想知道的是当用户点击取消按钮时如何取消文件上传?

1 个答案:

答案 0 :(得分:0)

我认为更改目标iframe“src”属性或内容会中止上传。

$(".imageCancel").click(function() {
    $(".upload_target").attr("src","#");
});​​