2011-07-08 23 views

回答

1

無法序列化文件上傳。 Javascript無權訪問將要上傳的文件數據。

上傳(不使用小程序/組件)的唯一方法是發佈文件輸入所在的表單。

0

是的,你可以@Guffa;我做到了。

<script src="http://code.jquery.com/jquery-latest.min.js"></script> 
<script type="text/javascript" src="http://{url}/js/ajaxfileupload.js"></script> 
<script src="http://{url}/js/jquery.form.js"></script> 

<script> 
(function() { 

var bar = $('.bar'); 
var percent = $('.percent'); 
var status = $('#status'); 

$('#txtrform').ajaxForm({ 
    beforeSend: function() { 
     status.empty(); 
     var percentVal = '0%'; 
     bar.width(percentVal) 
     percent.html(percentVal); 
    }, 
    uploadProgress: function(event, position, total, percentComplete) { 
     var percentVal = percentComplete + '%'; 
     bar.width(percentVal) 
     percent.html(percentVal); 
    }, 
    success: function() { 
     var percentVal = '100%'; 
     bar.width(percentVal) 
     percent.html(percentVal); 
    }, 
    complete: function(xhr) { 
     status.html(xhr.responseText); 
    } 
}); 

})();  
</script> 
<script> 
$(document).ready(function(){ 

    $("#txtrform").submit(function(){ 

     $.post($(this).attr('action'), $(this).serialize(), function(data) { 
      $("#col3").load("/include/txtrpbox/feed.php"); 
      $('input#txtrinput').val(''); 
     }); 

     return false; 
    }); 

}); 
</script> 
相關問題