62,266
社区成员
发帖
与我相关
我的任务
分享 <div>
<input type="file" id="chooseFile" style="display:none;"/>
<input type="button" id="submit" value="导入" onclick="showDlg()" />
</div>
<script type="text/javascript">
function showDlg()
{
var ob=$("#chooseFile")
ob.click();
$.ajax({
url:"webservice/importUserInfo.asmx/uploadExcel",
type:"GET",
dateType:"xml",
error:function()
{
alert("error!");
},
success:function()
{
alert("success!");
}
});
}
</script>
webservice/importUserInfo.asmx 代码
[WebMethod]
public string uploadExcel()
{
HttpFileCollection files = HttpContext.Current.Request.Files;
string uploadPath = "msg/";
uploadPath = HttpContext.Current.Server.MapPath("msg/");
if (files.Count > 0)
{
HttpPostedFile file = files[0];
string fileName = System.IO.Path.GetFileName(file.FileName);
string path = uploadPath + fileName;
file.SaveAs(path);
return "asdfe!123123";
}
return "asdfe!";
}