上传后重定向到URL

时间:2018-11-27 12:02:40

标签: jquery

上传文件后尝试重定向页面 http://jsfiddle.net/adampavlov/sfuon5y6/8/

$("#upload_link.first").on('click', function(e){
  e.preventDefault();
  $("#upload:hidden").trigger('click');
});

/*
  $("#upload_link.first").on('click', function(e){
      e.preventDefault();
      $("#upload:hidden").trigger('click');
  },
  function(){
      window.location.href = "http://jsfiddle.net/";
  });
*/

1 个答案:

答案 0 :(得分:2)

您可以使用文件输入字段的on change事件

$("#upload_link.first").on('click', function(e){
  e.preventDefault();
  $("#upload:hidden").trigger('click');
});
$('#upload:hidden').change(function(e){
      console.log(e.target.files[0])
      window.location.href = "http://jsfiddle.net/";
})  

http://jsfiddle.net/740kr2p1/