<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ////提交按钮 点击事件
        //if (MyFileUpload.HasFile)
        //{
        //    string filePath = Server.MapPath("~/UploadFiles/");
        //    string fileName = MyFileUpload.PostedFile.FileName;
        //    MyFileUpload.SaveAs(filePath + fileName);
        //    Response.Write("<p >上传成功!</p>");
        //}
        //else
        //{
        //    Response.Write("<p >请选择要上传的文件!</p>");
        //}
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="/Oimec/Styles/css/StyleSheet.css" rel="stylesheet" type="text/css" />
    <title></title>
    <script type="text/javascript">
        
        function up() {
            if (document.getElementById("File").value == "") {
                //document.getElementById("result").innerHTML = "请选择文件";
                alert("请选择文件");
            }
            else {
                var fileObj = document.getElementById("File").files[0];
                //创建xhr
                var xhr = new XMLHttpRequest();
                var url = "upFile.ashx";
                //FormData对象
                var fd = new FormData();
                fd.append("path", "D:\\");    //上传路径
                fd.append("file", fileObj);
                fd.append("acttime", new Date().toString());    //本人喜欢在参数中添加时间戳，防止缓存（--、）
                xhr.open("POST", url, true);
                xhr.send(fd);
                xhr.onreadystatechange = function () {
                    if (xhr.readyState == 4 && xhr.status == 200) {
                        var result = xhr.responseText;
                        document.getElementById("result").innerHTML = result;
                    }
                }
                //进度条部分
                xhr.upload.onprogress = function (evt) {
                    if (evt.lengthComputable) {
                        var percentComplete = Math.round(evt.loaded * 100 / evt.total);
                        document.getElementById('progress').value = percentComplete;
                        document.getElementById('progressNumber').style.width = percentComplete + "%";
                    }
                };
            }
        }
    </script>
    </head>
  
<body>
    <form id="form1" runat="server" enctype="multipart/form-data">
        <div>
            <!-- Insert content here -->
            <table width="1200" align="center" class="head" border="0" cellspacing="0" cellpadding="0">
                <tbody>
                    <tr>
                        <td class="logo"></td>
                        <td width="1000" class="biaoti"></td>
                        <td width="400"></td>
                    </tr>
                </tbody>
            </table>
            <br />
            <table width="1200" class="table" border="0" cellspacing="0" cellpadding="0">
                <tbody>
                    <tr>
                        <td height="13" class="title1" colspan="4">
                            <asp:Label ID="Label5" runat="server" Text="文档信息"></asp:Label></td>
                    </tr>
                    <tr>
                        <td height="19" class="tsbottomlabel" style="width: 10%">
                            <asp:Label ID="Label4" runat="server" Text="文件名称"></asp:Label></td>
                        <td class="tsbottomtext" style="width: 80%">
                            <input id="txtName" type="text" style="width: 50%" /></td>
                    </tr>
                    <tr>
                        <td height="19" class="tsbottomlabel" style="width: 10%">
                            <asp:Label ID="Label1" runat="server" Text="业务类型"></asp:Label></td>
                        <td class="tsbottomtext" style="width: 80%">
                            <input id="txtBusinessType" type="text" style="width: 50%" /></td>
                    </tr>
                    <tr>
                        <td height="33" class="tsbottomlabel" style="width: 10%">
                            <asp:Label ID="Label2" runat="server" Text="适应业务简述"></asp:Label></td>
                        <td class="tsbottomtext" style="width: 80%">
                            <input id="txtBusinessDescribe" type="text" style="width: 100%" columns="5" textmode="MultiLine" aria-orientation="horizontal" />
                        </td>
                    </tr>
                    <tr>
                        <td height="19" class="tsbottomlabel" style="width: 10%">
                            <asp:Label ID="Label3" runat="server" Text="附件"></asp:Label></td>
                        <td class="tsbottomtext" style="width: 80%">
                            <input id="File" type="file" name="fileUpload" /></td>
                        <%--onchange="document.getElementById('textfield').value=this.value"--%>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <input type="button" value="上传" onclick="up()" />
                            <%--<input type="button" id="btnSubmit" value="提交" style="width:50px" onclick="upload()"/>--%>
                            <%--<asp:Button ID="btnSubmit" runat="server" Text="Button" OnClick="btnSubmit_Click" />--%>
                        </td>
                    </tr>
                </tbody>
            </table>
            <div>
                <input type="button" value="添加附件(Add)" onclick="//addFile('myfile')">
            </div>
            <div id="myfile">
            </div>
        </div>
    </form>
</body>
</html>
