上传控件用着心烦,其实直接表单传就行,简单易行
1、首先form这么写
<form action="WebService.asmx/FileUpload" method="post" enctype="multipart/form-data">
WebService.asmx/FileUpload是你的上传接口,我这里用的是WebService,注意方法不能有参数,否则会报错
2、接着 你把一堆表单要传的input 数据 都给起个name,后台取数据用HttpContext.Current.Request["name"]
有些后台数据就直接<input type="hidden" id="name" runat="server" />,记得要放在form里才行
3、上传文件就用 <input id="fileupload" name="fileupload" type="file" value=" " />
4、上传接口方法里判断 HttpContext.Current.Request.Files.Count 有没有文件
HttpContext.Current.Request.Files[0].FileName 文件名
有的话用 HttpContext.Current.Request.Files[0].SaveAs(fullPath);保存,如果多个的话无非就是Files[]数组里喽。
服务器网站物理路径 HttpContext.Current.Request.ApplicationPath
就那么简单,搞什么乱七八糟啊的控件,其它参数自行研究。