• Javascript Fromdata 与jQuery 实现Ajax文件上传


    <!DOCTYPE html>
    <html>
    <head>
    	<title>ajax</title>
    	<script type="text/javascript" src="js/jquery.js"></script>
    	<meta charset="utf-8" />
    	<style type="text/css">
    	form{
    		position: relative;
    	}
    	ul li{
    		list-style: none;
    	}
    	.divide ul li img{
    		 100px;
    		border: 3px solid #eeeeee;
    	}
    	.selected{
    		border: 3px solid #0099aa;
    	}
    	form input{
    		position: absolute;
    		top: 0;
    		left: 0;
    		padding: 20px;
    		opacity: 0;
    	}
    	button{
    		padding: 20px;
    		background: #0099aa;
    		border-radius: 3px;
    		border: 2px solid #333333;
    		color: #ffffff;
    		font-size: 18px;
    	}
    	.loading{
    		display: none;
    	}
    	</style>
    </head>
    <body>
     
    	
    	<input type="file" id="file" multiple />
    	
    	<div class="loading"><img src="loading.gif" /></div>
    	<div class="divide">
    		<ul>
    		
    		</ul>
    	</div>
    	
    	<script type="text/javascript">
    	$(function(){
    		$("#file").change(function(){
    
    				data = new FormData();
    				data.append('files', $('#file')[0].files[0]);
    				$.ajax({
    					type: "post",
    					url: "upload.php",
    					processData: false,
    					contentType: false,
    					data: data,
    					success: function(a, b, c){
    						$("div ul").append("文件上传成功!<li><img src='" + a + "' /> </li>");
    					}
    				});
    
    			});
    
    
    	});
    	</script>
    </body>
    </html>
    

      

  • 相关阅读:
    用VisualSVN做项目版本控制
    jQuery 停止动画
    jQuery 效果
    jQuery 效果
    jQuery 效果
    jQuery 事件
    jQuery 选择器
    jQuery 语法(一)
    Form.ShowWithoutActivation 属性
    C#里面中将字符串转为变量名
  • 原文地址:https://www.cnblogs.com/chenshuo/p/3895745.html
Copyright © 2020-2023  润新知