jquery插件实现文件上传

来源:互联网 发布:win32界面编程 编辑:程序博客网 时间:2024/05/21 04:23
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
 <script language="JavaScript" src="/js/jquery-1.8.3.js" ></script>
 <script type="text/javascript" src="/js/ajaxfileupload.js"></script>
 

<script type="text/javascript">

$(function(){
    //上传图片
    $("#btnUpload").click(function() {
            alert(ajaxFileUpload());
    });
 });

 $.ajaxFileUpload({
         url: 'http://192.168.23.174:8080/WeiKe/fileUpload?action=DruqwPmF1keVPn1s15Cy&userId=BC1000037589',
         type: 'post',
         secureuri: false, //一般设置为false
         fileElementId: 'file', // 上传文件的id、name属性名
         dataType: 'text', //返回值类型,一般设置为json、application/json
         success: function(data, status){  
             alert(data);
         },
         error: function(data, status, e){
             alert(e);
         }
     });
     //return false;
 }
</script>
</head>
<body>

 <input type="file" id="file" name="myfile" />

<input type="button" id="btnUpload" onclick="UpladFile()" value="上传" />
</body>
</html>

0 0
原创粉丝点击