点击回首页
我的浏览记录 | | 帮助?
当前位置:
首页>> 企业网站>> MVC通用企业门户网站源码>> 源文件浏览
[商业版 299金币] WebForm,下载次数:33 次 | 关键字: mvc easyui 门户网站

源码截图

源码目录树

当前路径:PD.Web/Controllers/UploadImgController.cs     using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace PD.Web.Controllers
{
    public class UploadImgController : Controller
    {
        //
        // GET: /UploadImg/
        public HttpContext context = System.Web.HttpContext.Current;

        [HttpPost]
        public ActionResult uploadID(HttpPostedFileBase head)
        {
            try
            {
                if ((head == null))
                {
                    return Json(new { msg = 0 });
                }
                else
                {
                    String dirPath = context.Server.MapPath("~/userfiles/");
                    var supportedTypes = new[] { "jpg", "jpeg", "png", "gif", "bmp" };
                    var fileExt = System.IO.Path.GetExtension(head.FileName).Substring(1);
                    if (!supportedTypes.Contains(fileExt))
                    {
                        return Json(new { msg = -1 });
                    }

                    if (head.ContentLength > 1024 * 1000 * 10)
                    {
                        return Json(new { msg = -2 });
                    }
                    var filename = Common.Other.GetGuid() + "." + fileExt;
                    dirPath += "Agency/";
                    if (!Directory.Exists(dirPath))
                    {
                        Directory.CreateDirectory(dirPath);
                    }
                    var filepath = Path.Combine(dirPath, filename);
                    try
                    {
                        System.IO.File.Delete(filepath);
                    }
                    catch
                    {

                    }
                    head.SaveAs(filepath);
                    return Content("<script>window.parent.uploadSuccess('上传成功|" + filename + "');</script>");
           ...
对不起,完整源码文件,请先购买后再查看
关于我们 | 顾问团队 | 发展历程 | 联系我们 | 源码上传
联系电话(Tel):4008-010-151(免长途) 企业QQ:2852517674
地址:北京市海淀区中关村鼎好大厦A座二层 邮编:100080
Room A-801,Dinghao Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2015. 京ICP备09089570号 | 京公网安备11010702000869号
分享该页面
关闭侧边栏