<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta charset="UTF-8"> <title></title> <link href="http://admin.vlcms.com/Public/icon.ico" type="image/x-icon" rel="shortcut icon"> <link rel="stylesheet" type="text/css" href="__CSS__/base.css" media="all"> <link rel="stylesheet" type="text/css" href="__CSS__/common.css" media="all"> <link rel="stylesheet" type="text/css" href="__CSS__/module.css"> <link rel="stylesheet" type="text/css" href="__CSS__/style.css" media="all"> <link rel="stylesheet" type="text/css" href="__CSS__/default_color.css" media="all"> <script type="text/javascript" src="__STATIC__/jquery-2.0.3.min.js"></script> <script src="__STATIC__/layer/layer.js" type="text/javascript"></script> </head> <style> html { min-width:100%; } body { padding: 0px; } </style> <body> <div id="main" class="main" style="min-height: 342px;margin-top: 20px;padding-left: 50px;"> <table border="0" cellspacing="0" cellpadding="0"> <tr style="padding: 10px;height: 50px;"> <td class="l" style="width: 100px;">文件名称:</td> <td class="r" style="margin-left: 10px;"> <input type="text" id="filename" name="company_name" value="" placeholder="请输入文件名称"> </td> </tr> <tr style="padding: 10px;height: 50px;"> <td class="l">文件选择:</td> <td > <input type="file" id="fileinput" name="file"> </td> </tr> </table> <div class="jssearch search_list fl cf"> <div class="input-list"> <div class="sch-btn uploadfile" style="width: 100px;padding: 5px;">确认添加</div> </div> </div> </div> <script> $(function(){ $(".uploadfile").on("click",function(){ var formData = new FormData(); var filename = $("#filename").val(); if(filename == ''){ layer.msg("文件名不能为空"); return false; } formData.append("file_name", filename); formData.append("file", document.getElementById("fileinput").files[0]); var index = layer.load(); $.ajax({ url:"{:U('PromoteCompany/saveFile')}", type:"post", data:formData, processData:false, contentType:false, success:function(data){ layer.close(index); if(data.status == 1){ delete data.status; delete data.info; window.parent.addFile(data); }else{ layer.alert(data.info); } }, error:function(e){ } }); }) }); </script> </body> </html>