PageAdmin网站内容管理系统(CMS)交流论坛

注册

 

QQ登录

只需一步,快速开始

发新话题 回复该主题

关于下载页面获取文件大小的方法!折腾大半夜终于搞定 [复制链接]

1#
折腾大半夜终于搞定下载页面获取文件的方法,先上张图欣赏下效果,还有句话告诉老大,我是个搞前端的,现在活生生被逼得去研究后端,哎!!

然后上模版页面代码
  1. @{
  2.     string templateDirectory = ViewBag.TemplateDirectory;
  3.     int columnId = Html.CurrentColumnId();//当前栏目id
  4.     PageInfo pageInfo = new PageInfo()
  5.     {
  6.         PageSize = 10,//每页显示12条数据
  7.         CurrentPage = (int)ViewBag.CurrentPage //当前页码,系统预设
  8.     };
  9.     var dataList = Html.InfoDataList(new { ColumnId = columnId }, null, null, pageInfo);
  10.     var columnContentData = Html.ColumnContentData();
  11.     string zdytitle = columnContentData.Zlmlmmc;
  12. }

  13. @Html.Partial("xBannerPartial")

  14. <div class="container">
  15.     @Html.Partial("BreadcrumbPartial")
  16. </div>

  17. <div class="container">
  18. <div align="center" class="xiazaizhuanqu"><div class="kuang"><span class="s1">下载中心</span></div></div>
  19. <div class="row margin-top-20">

  20.     <div class="margin-top-10">
  21.         <div class="zlm_news_mx web_wzwc_com">
  22.             @foreach (var item in dataList)
  23.             {
  24.                 string title = item.Title;
  25.                 if (title.Length > 30)
  26.                 {
  27.                     title = title.Substring(0, 30) + "...";
  28.                 }
  29.                 string introduction = item.Introduction;
  30.                 if (introduction.Length > 260)
  31.                 {
  32.                     introduction = introduction.Substring(0, 260) + "...";
  33.                 }
  34.                 string date = item.Thedate.ToString("MM/dd");
  35.                 string dates = item.Thedate.ToString("yyyy");
  36.                 string url = Html.InfoDataUrl((int)item.ColumnId, (int)item.Id);
  37.                 string thumbnail = item.Thumbnail;
  38.                 {

  39.                     <div class="download">
  40.                         
  41.                             <div class="download_lb">
  42.                                 <div class="lbtite">

  43.                                         <p class="news-title">
  44.                                             @title <span>  【@introduction】</span>
  45.                                         </p>

  46.                                 </div>
  47.                                  @foreach (var itemq in Html.AttachmentDataList(new { ParentId=(int)item.Id , ParentTable = "news",

  48. ParentField = "content" })) //这里获取附件表里上传的文件大小,我是用的新闻信息表改的,所以用的news,我有时候需要上传多个附件,所以没有另外添加附件的字段,用的是编辑器里面附件上传的。
  49.     {
  50.                                 <div class="lbsize">
  51.                               <span>@((itemq.Size/1024).ToString("F3")) MB</span><!--这里的Size获取的是kb,以为上传到编辑器里面的附近默认是kb,需要/1024转换成MB,如果你需要转行成GB 就需要写成(itemq.Size/1024/1024),后面的F3代表只取小数点后面3位并且四舍五入,如果你需要2位,就写F2,4位F4 以此类推-->
  52.                                 </div>
  53.                              <div class="lbdown"><a href="@itemq.Path" target="_self" class="clearfix" title="@introduction">下载</a></div>
  54.                              }
  55.                             </div>
  56.                         
  57.                         <div>

  58.         </div>
  59.                     </div>
  60.                     

  61.                 }
  62.             }
  63.         
  64.         </div>
  65.         
  66.             @Html.Partial("PagebreakPartial", pageInfo)
  67.     </div>
  68. </div>
  69. </div>
复制代码
分享 转发
TOP
2#

回复 2楼5236662的帖子

是的 但我想获取编辑器里面上传的时候附件前面自带的小图标,还在折腾,有好的办法吗?
TOP
发新话题 回复该主题