zoukankan      html  css  js  c++  java
  • Baidu UEditor .net 下修改默认上传路径

     public override void Process()
        {
            byte[] uploadFileBytes = null;
            string uploadFileName = null;
    
            if (UploadConfig.Base64)
            {
                uploadFileName = UploadConfig.Base64Filename;
                uploadFileBytes = Convert.FromBase64String(Request[UploadConfig.UploadFieldName]);
            }
            else
            {
                var file = Request.Files[UploadConfig.UploadFieldName];
                uploadFileName = file.FileName;
    
                if (!CheckFileType(uploadFileName))
                {
                    Result.State = UploadState.TypeNotAllow;
                    WriteResult();
                    return;
                }
                if (!CheckFileSize(file.ContentLength))
                {
                    Result.State = UploadState.SizeLimitExceed;
                    WriteResult();
                    return;
                }
    
                uploadFileBytes = new byte[file.ContentLength];
                try
                {
                    file.InputStream.Read(uploadFileBytes, 0, file.ContentLength);
                }
                catch (Exception)
                {
                    Result.State = UploadState.NetworkError;
                    WriteResult();
                }
            }
    
            Result.OriginFileName = uploadFileName;
    
            var savePath = PathFormatter.Format(uploadFileName, UploadConfig.PathFormat);
            var localPath = Server.MapPath(savePath);
            try
            {
                if (!Directory.Exists(Path.GetDirectoryName(localPath)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(localPath));
                }
                File.WriteAllBytes(localPath, uploadFileBytes);
                //增加你的上传逻辑代码
            }
            catch (Exception e)
            {
                Result.State = UploadState.FileAccessError;
                Result.ErrorMessage = e.Message;
            }
            finally
            {
                WriteResult();
            }
        }

    文件路径
    ueditor etApp_CodeUploadHandler.cs

  • 相关阅读:
    selenium中webDriver模块的常用方法
    java web Project Explorer误删解决方法
    java web开发前后端中文配置
    常见Filed Types
    类的展现
    面向对象:类与运算符
    面向对象定义类,属性
    筛选元素
    try : finally语句
    捕获异常try:except
  • 原文地址:https://www.cnblogs.com/zhaogaojian/p/11647001.html
Copyright © 2011-2022 走看看