博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
在线编辑器CKEditor,多图上传功能实现
阅读量:4655 次
发布时间:2019-06-09

本文共 2877 字,大约阅读时间需要 9 分钟。

界面设计:

批量上传时:

 

 

下面是代码:

aspx 代码:

1   2                          3                              5                          6                          7                               9                         10                     11                     12                         13                             
16 17
View Code

js 方法:

1   
View Code

 

服务端代码:

1 { 2         FileSettingEntity fileVaild = null; 3         fileVaild = FileManger.GetFileSetting((int)ESourceType.fromSPUDescription); 4         if (file.ContentLength > fileVaild.Length) 5         { 6             return ""; 7         } 8         else 9         {10             FileEntity fentity = null;11             try12             {13                 fentity = Gasgoo.B2C.Common.FileUpload.Upload(file, ESourceType.fromSPUDescription, SpuId.ToType
(), 0, true);14 15 }16 catch17 {18 return "";19 }20 string ServiceImages = fentity.FileID + Path.GetExtension(Request.Form["fileName"].ToLower());21 if (!String.IsNullOrEmpty(ServiceImages))22 {23 return ServiceImages;24 }25 return "";26 }27 }
View Code

AJAX:

1  context.Response.ContentType = "text/plain"; 2         #region 订单投诉跟进图片 add it by wangyy 3         string kid = WebHelper.GetFormHtmlValue
("Kid", ""); 4 string imgs = CacheManager.CreateCache("Manage_Image_Upload").Get
(kid); 5 CacheManager.CreateCache("Manage_Image_Upload").Remove(kid); 6 #endregion 7 8 9 #region SPU图片 add it by wangyy10 string spuId = WebHelper.GetFormHtmlValue
("spuId", "");11 string Spu_imgs = CacheManager.CreateCache("SPU_Image_Upload").Get
(spuId);12 CacheManager.CreateCache("SPU_Image_Upload").Remove(spuId);13 #endregion14 15 16 // type 1:SPU商品详情图片 0:订单跟进投诉图片17 int type = WebHelper.GetFormHtmlValue
("type", 0);18 List
list = new List
();19 string strJson = string.Empty;20 strJson = "[";21 if (type == 0)22 {23 list = FileFactory.GetItemImagesByFileArray(imgs, ESourceType.formOrderFollow);24 }25 else26 {27 list = FileFactory.GetItemImagesByFileArray(Spu_imgs, ESourceType.fromSPUDescription);28 29 }30 if (list != null && list.Count > 0)31 {32 foreach (FileEntity item in list)33 {34 strJson += "{\"fileName\":\"" + item.FileName + "\",\"filePath\":\"" + item.ImageUrl + "\"},";35 }36 }37 strJson = strJson.TrimEnd(',') + "]";38 context.Response.Write(strJson);39 }
View Code

      其中有很多框架中的代码引用,只提供一种思路,又不熟悉和有问题的地方请联系我 QQ:1627298416,欢迎指教

转载于:https://www.cnblogs.com/q101301/p/4685428.html

你可能感兴趣的文章