码迷,mamicode.com
首页 > Web开发 > 详细

异步上传文件

时间:2016-06-06 23:25:50      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:

 

<!DOCTYPE html>
 
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <script src="~/Scripts/jquery-1.8.2.min.js"></script>
    <title>Index</title>
    <script>
        $(function() {
            $(:button).click(function () {
                var formData = new FormData();
                var file = $("input[type=‘file‘]")[0].files[0];
                formData.append("files", file);
                $.ajax({
                    url: /Upload/Upload,  //server script to process data
                    type: POST,
                      
                    //Ajax事件
                    //beforeSend: beforeSendHandler,
                    //success: completeHandler,
                    //error: errorHandler,
                    // Form数据
                    data: formData,
                    //Options to tell JQuery not to process data or worry about content-type
                    cache: false,
                    contentType: false,
                    processData: false
                });
            });
        });
 
         
    </script>
</head>
<body>
    <form enctype="multipart/form-data">
        <input name="file" type="file" multiple="multiple" />
        <input type="button" value="Upload" />
        <input type="text" name="userName" value="ice" />
    </form>
     
</body>
</html>

 

异步上传文件

标签:

原文地址:http://www.cnblogs.com/xiaoliu66007/p/5565365.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!