增加当前图像显示大小功能

This commit is contained in:
Argo-Lenovo 2016-12-10 12:23:59 +08:00
parent 9e20c02525
commit 87154584a7
5 changed files with 34 additions and 4 deletions

View File

@ -261,6 +261,7 @@
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Models\InfosModel.cs" />
<Compile Include="Models\LockModel.cs" />
<Compile Include="Models\MessageCountModel.cs" />
<Compile Include="Models\QueryDictOption.cs" />

View File

@ -106,7 +106,7 @@ namespace Bootstrap.Admin.Controllers
/// <returns></returns>
public ActionResult Infos()
{
var v = new NavigatorBarModel("~/Admin/Infos");
var v = new InfosModel("~/Admin/Infos");
return View(v);
}
/// <summary>

View File

@ -0,0 +1,28 @@
using System.IO;
using System.Web;
namespace Bootstrap.Admin.Models
{
/// <summary>
///
/// </summary>
public class InfosModel : NavigatorBarModel
{
/// <summary>
/// 获得/设置 头像文件大小
/// </summary>
public long Size { get; set; }
/// <summary>
///
/// </summary>
/// <param name="url"></param>
public InfosModel(string url) : base(url)
{
var fileName = HttpContext.Current.Server.MapPath(Icon);
if (File.Exists(fileName))
{
Size = new FileInfo(fileName).Length;
}
}
}
}

View File

@ -4,12 +4,13 @@
$('#fileIcon').fileinput({
uploadUrl: Infos.url,
language: 'zh',
maxFileSize: 5000,
allowedFileExtensions: ['jpg', 'png', 'bmp', 'gif', 'jpeg'],
initialPreview: [
preIcon
],
initialPreviewConfig: [
{ caption: "现在头像", size: 730, showZoom: false },
{ caption: "现在头像", size: $('#fileIcon').attr('data-init'), showZoom: false },
],
initialPreviewAsData: true,
overwriteInitial: true,

View File

@ -1,4 +1,4 @@
@model NavigatorBarModel
@model InfosModel
@{
ViewBag.Title = "个人中心";
Layout = "~/Views/Shared/_Admin.cshtml";
@ -72,7 +72,7 @@
<div class="panel-body">
<form enctype="multipart/form-data">
<div class="form-group">
<input id="fileIcon" class="file" type="file">
<input id="fileIcon" class="file" type="file" data-init="@Model.Size">
</div>
</form>
</div>