ajaxupload 上传文件

使用的JS文件:

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
   
 <!-- Required for jQuery dialog demo-->
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript"></script>
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-darkness/jquery-ui.css" type="text/css" media="all" />

    <!-- AJAX Upload script itself doesn't have any dependencies-->
    <script type="text/javascript" src="../ajaxupload.js"></script>

 

 

<li id="example1"><div id="upload_button"><!--<input type="submit" class="btnUpload" value=""/>-->上传文件</div>
<li id="example2"><div id="upload_text"></div>
		
        <p>已上传的文件列表:</p> 
            <ol class="files">
            	<div id="del" style="display:none;">
            		
                   <li style="float:left; width:50px;"></li>
                    <li style="float:left;"><a href="#;" onClick="deleteFile('1')">删除</a></li>
            	</div>
            </ol>
</li>

 

  $(document).ready(function(){

		var button = $('#upload_button'), interval;
		var button_text = $('#upload_text'), interval;
		var fileNum = "one";
		new AjaxUpload(button, {
			action: '../proposalannex/annex_save.html', 
			name: 'annex',                   //后台取此名来进行文传上传
			onSubmit : function(file, ext){	
				button_text.text('文件上传中');
				this.disable();
				interval = window.setInterval(function(){
					var text = button_text.text();
					if (text.length < 13){
						button_text.text(text + '.');					
					} else {
						button_text.text('Uploading');				
					}
				}, 200);
			},
			onComplete: function(file, response){
				button_text.text('文件上传中');							
				window.clearInterval(interval);							
				this.enable();				
			    if(response != "");{
					//button_text.text('文件上传成功!');
					button_text.text('');
					alert('文件上传成功');
					$("#annexId").val(response);
					this.enable();	
			    }
				$('<li></li>').appendTo('#example2 .files').text(file);
				document.getElementById('del').style.display='block';							
			}
		});
  });

 

 

其它上传文件方式:http://lisanlai.iteye.com/blog/680785

你可能感兴趣的:(JavaScript,jquery,UI,Ajax,css)