日期:2014-05-16  浏览次数:20388 次

使用fileuploader.js实现文件上传
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type"content="text/html; charset=utf-8" />  
<title>file uploader</title>  
<script type="text/javascript"src="./js/fileuploader.js"></script>  
<link rel="stylesheet"type="text/css" href="./css/fileuploader.css"/>  
<script type="text/javascript">  
window.onload = function() {  
    new qq.FileUploader({  
            element:document.getElementById("uploader"),  
             action: 'upload',
             debug:true,
             allowedExtensions:['jpg'], 
             sizeLimit: 819200, //800k 
             messages: {
             typeError: "文件错误:只允许{extensions}类型的文件。{file}. ",
             sizeError: "文件错误:文件大小不能超过{sizeLimit}字节。{file}.",
             emptyError: "文件错误:不能上传空文件。{file}.",
             onLeave: "文件正在上传,离开将终止上传操作?"
         },
         showMessage: function(message){
             alert(message);
         }
        });  
}  
</script>  
</head>  
   
<body>  
<div id="uploader">
     <noscript><p>改浏览器不支持javascript!</p></noscript>   
</div>  
</body>  
</html>