WebMvc/Areas/Controls/Controllers/UploadFilesController.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;

namespace WebMvc.Areas.Controls.Controllers
{
    public class UploadFilesController : MyController
    {
        //
        // GET: /Controls/UploadFiles/

        public ActionResult Index()
        {
            return View();
        }

        public string Upload()
        {
            Response.ContentType = "text/plain";
            string str1 = Request["str1"];
            string str2 = Request["str2"];
            string msg;
            if (!Common.Tools.CheckLogin(out msg))
            {
                return "您不能上传文件";
            }

            //接收上传后的文件
            HttpPostedFileBase file = Request.Files["Filedata"];

            if (false && !"".Contains(Path.GetExtension(file.FileName), StringComparison.CurrentCultureIgnoreCase))
            {
                return "您上传的文件类型不被允许";
            }

            //获取文件的保存路径
            string uploadPath;
            string uploadFullPath = Server.MapPath(getFilePath(out uploadPath));

            //判断上传的文件是否为空
            if (file != null)
            {
                if (!Directory.Exists(uploadFullPath))
                {
                    Directory.CreateDirectory(uploadFullPath);
                }
                //保存文件
                string newFileName = getFileName(uploadFullPath, file.FileName);
                string newFileFullPath = uploadFullPath + newFileName;
                try
                {
                    int fileLength = file.ContentLength;
                    file.SaveAs(newFileFullPath);
                    return "1|" + (uploadPath + newFileName) + "|" + fileLength.ToString("###,###") + "|" + newFileName;
                }
                catch
                {
后面还有 61 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。