1. 程式人生 > >html5前端實現檔案分割上傳

html5前端實現檔案分割上傳

<body>
	<form action="${ctx }/file/uppicture" enctype="multipart/form-data"  method="post" >
		<input type="file" name="file"/> <br><br><br>
		<input type="submit" value="form提交"/> <!-- form 表單提交--><br><br><br>
		<input type="button" value="ajax提交"/> <!-- ajax 提交檔案 -->
	</form>
	
	<script type="text/javascript">
		$(function(){
			$("input[type=button]").click(function(){
				 var files = $("input[type=file]")[0].files;
				 console.log(files);
				 console.log(files[0].size);
				 console.log(files[0].name);
				 
				 var index = 1024*1024*10;
				 
				 var lump = files[0].size/index;
				 console.log(lump);
				 var num = parseInt(lump);
				 console.log(num);
				 
			});
		});
	</script>
</body>