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

  • 相关阅读:
    [CALayer release]: message sent to deallocated instance 的原因
    Java格式化打印及数字格式化
    Java断言关键字
    Java数值使用下划线
    Java数组复制
    .net你必须知道的事儿 1.5
    .net你必须知道的事儿 1.4
    .net你必须知道的事儿 1.3
    .net你必须知道的事儿 1.2
    .net你必须知道的事儿 1.1
  • 原文地址:https://www.cnblogs.com/zhaogaojian/p/11647001.html
Copyright © 2011-2022 走看看