asp.net不使用FileUpload时如何实现文件上传 如果不使用asp.net的FileUpload控件,只用input type="file" ,该如果实现文件上传?谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://zhidao.baidu.com/question/139371284.html搜的,看下吧。 <input type="file" id="xxx" name="xxx" class="normal" />var C = Request.Files[0];if (c != null && c.ContentLength > 0){ byte[] fileContent = new byte[c.ContentLength];........ c.InputStream.Read(fileContent, 0, c.ContentLength);........} 那就只能用第三方控件了例如flashupload input type=file 和asp.net的fileupload本质上是一个东西啊 我知道本质上是一个东西,但现在是不能让那个input runat="server",所以用Request.Files也获取不到…… 因为我要实现的功能是:事先不知道要上传多少个文件,在页面有一个“添加附件”的控钮,每点一次就js动态生成一个input type=file,所以不能runat="server"。这种情况要如何实现,邮箱里基本都有这种功能的…… <input type=file /><input type=file />foreach(HttpPostedFile file in Request.Files){file.SaveAs} 如果input type=file没有标记runat=server的话,Request.Files.Count为0 的啊…… <input id="upload_A" name="upload_A" type="file" class="inputText" style="width: 350px; display:none;" runat="server" />HttpFileCollection Files = HttpContext.Current.Request.Files;for (int i = 0; i < Files.Count; i++){HttpPostedFile PostedFile = Files[i];if (PostedFile.ContentLength > 0){string FileName = PostedFile.FileName;}}否则使用ftpwebrequest,web services上传 谁说的?看看MSDN上关于HttpRequest.Files的说明:仅当 HTTP 请求 Content-Type 值为“multipart/form-data”时,才会填充该文件集合。 Request.Files[i]这种方法你用过没有??给你例子都不看的。 form标签加入 enctype="multipart/form-data" 如果Count为0的话你用Files[i]]来读的不就是null值吗?切…… 在form里添加enctype="multipart/form-data"就行啦,谢谢各位! iewebcontrols 显示问题 在asp.net中如何记录对方IP和操作系统 最好有方法 高手们 救命啊 客户端如何在操作服务器端的文件夹 ASP.NET弹出对话框,点击确定以后,页面样式改变 Form身份验证中的角色管理 为什么我给的分这么高,却没人来接啊!!!!只是一个很简单的问题! 一个ajax问题的请教 asp.net的回复 想写一个计算在网页停留时间的WEB程序,大家可否指点下我? 打包高手请进,打包完成后运行有错 问一个vb.net的数组问题 图上的功能用<asp:Repeater能实现吗?谁给个例子给谁分
搜的,看下吧。
if (c != null && c.ContentLength > 0)
{
byte[] fileContent = new byte[c.ContentLength];
........
c.InputStream.Read(fileContent, 0, c.ContentLength);
........
}
例如flashupload
<input type=file />foreach(HttpPostedFile file in Request.Files){
file.SaveAs
}
style="width: 350px; display:none;" runat="server" />HttpFileCollection Files = HttpContext.Current.Request.Files;
for (int i = 0; i < Files.Count; i++)
{
HttpPostedFile PostedFile = Files[i];
if (PostedFile.ContentLength > 0)
{
string FileName = PostedFile.FileName;}
}
否则使用ftpwebrequest,web services上传
谁说的?
看看MSDN上关于HttpRequest.Files的说明:
仅当 HTTP 请求 Content-Type 值为“multipart/form-data”时,才会填充该文件集合。
给你例子都不看的。