我想知道这个可以上传多个图片怎么实现存到数据库,或者异步也行,还有就是从数据库读取出来展现在页面中 求详细点的代码?谢谢了
我试了下还是不行 啊
使用jQuery负责界面,后台实现一个ashx或者找个库
参考 http://www.codeproject.com/Articles/68374/Upload-Multiple-Files-in-ASP-NET-using-jQuery
我按他的做了还是不行啊!
<asp:FileUpload ID="FileUpload1" runat="server" class="multi" />
里面的class="multi"没用吧!
自己使用写一个就的了 用微软自带的 或者用二进制写一个
asp.net C#
.aspx主要代码
<TR> <Th><%=reqTitle %> No.:</th> <td> <asp:TextBox runat="server" Css /> (*)</TD> </TR> <TR> <Th>File:</th> <td> <input runat="server" type="file" >(*)</TD> </TR> <TR> <TD colspan=2 align=middle><asp:Button runat="server" Text="" OnClick="btnUpload_Click" Css onMouseDown="this.style.backgroundImage='url(../Sales/images/Uploada3.gif)'" onMouseOver="this.style.backgroundImage='url(../Sales/images/Uploada2.gif)'" onMouseOut="this.style.backgroundImage='url(../Sales/images/Uploada1.gif)'"/> <input type="button" name="close" value="" onMouseDown="this.style.backgroundImage='url(../Sales/images/close3.gif)'" onMouseOver="this.style.backgroundImage='url(../Sales/images/close2.gif)'" onMouseOut="this.style.backgroundImage='url(../Sales/images/close1.gif)'" onclick="javascript:self.close();"/></TD>
</TR>
.cs主要代码
if (File1.PostedFile.ContentLength != 0) { fileName = FileUtility.UploadFile(File1, Server.MapPath("~/PFImage/"),DateTime.Now.ToString("yyyyMMddHHmmddfff")+ System.IO.Path.GetFileName(File1.PostedFile.FileName)); if (fileName == "") { //上传失败
return; } else { //上传成功
} }
文件上传类主要代码
命名空间
using System.IO; using System.Net;
#region 上传文件 /// <summary> /// 上传文件 /// </summary> /// <param name="inputFile">System.Web.UI.HtmlControls.HtmlInputFile</param> /// <param name="path">文件存储目录,物理文件路径</param> /// <returns></returns> public static string UploadFile(System.Web.UI.HtmlControls.HtmlInputFile inputFile, string path,string namedFileName) { try { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); }
inputFile.PostedFile.SaveAs(path + namedFileName); } catch (Exception) { namedFileName = ""; }
return namedFileName; } #endregion
加我的群相互交流问题解决问题 183450771