首页 新闻 会员 周边 捐助

关于Telerik中Editor添加上传图片报错的问题

0
悬赏园豆:20 [已关闭问题] 关闭于 2012-07-25 14:49

在使用mvc3.0项目中使用到了Telerik中Editor,做为编辑器很满意,按官方给的Demo也全部实现出来了功能使用也正常。使用vs2010运行后Editor功能全部能使(包括上传图片)。但是发布到服务器上之后,editor中其它功能都正常,唯独添加图片的时候会报'Error! The requested Url returned 500' -intenal server Error .哪位有用过editor功能是否遇到这种问题请问是如何解决的?

问题补充:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Telerik.Web.Mvc.UI;
using System.IO;
using Com.Hospira.Sox.Utility;
using log4net;

namespace Com.Hospira.Controllers
{
    public class ImageBrowserController : EditorFileBrowserController    
    {        
        private const string contentFolderRoot = "~/Content/";
        private const string prettyName = "Editor/";        
        private static readonly string[] foldersToCopy = new[] { "~/Content/Editor" };          
         protected ILog logger = null;

         public ImageBrowserController()
         {
             logger = LogManager.GetLogger(this.GetType());
             logger.Info("File Name : ImageBrowserController");
         }
        public override string[] ContentPaths        
        {            
            get            
            {                
                return new[] 
                {
                    CreateUserFolder()
                };            
            }        
        }        
        private string UserID        
        {            
            get {
                var obj = Session[GlobalConstant.AUTHENTICATION_LOGINSESSIONKEY];                
                if (obj == null)                
                {
                    Session[GlobalConstant.AUTHENTICATION_LOGINSESSIONKEY] = obj = DateTime.Now.Ticks.ToString();                
                }                
                return (string)obj;            
            }        
        }                
        private string CreateUserFolder()        
        {
            
            var userFolder = Path.Combine("TempFiles", UserID);            
            var virtualPath = Path.Combine(contentFolderRoot, userFolder, prettyName);            
            var path = Server.MapPath(virtualPath);
            logger.Info("Editor path" + path);
            try
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                    foreach (var sourceFolder in foldersToCopy)
                    {
                        CopyFolder(Server.MapPath(sourceFolder), path);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("ImageBrowserController.CreateUserFolder",ex);
            }
            return virtualPath;        
        }        
        private void CopyFolder(string source, string destination)        
        {                
            try
            {
                if (!Directory.Exists(destination))
                {
                    Directory.CreateDirectory(destination);
                }
                foreach (var file in Directory.EnumerateFiles(source))
                {
                    var dest = Path.Combine(destination, Path.GetFileName(file));
                    System.IO.File.Copy(file, dest);
                }
                foreach (var folder in Directory.EnumerateDirectories(source))
                {
                    var dest = Path.Combine(destination, Path.GetFileName(folder));
                    CopyFolder(folder, dest);
                }
            }
            catch(Exception ex)
            {
                logger.Error("ImageBrowserController.CopyFolder",ex);
            }
        }    
    }
}
wangming的主页 wangming | 初学一级 | 园豆:41
提问于:2012-07-24 09:49
< >
分享
所有回答(2)
0

看看是不是上传目录的写入权限有问题

gunsmoke | 园豆:3592 (老鸟四级) | 2012-07-24 12:53

不是这个问题,因为我尝试过在服务上写文件是能生成的

支持(0) 反对(0) wangming | 园豆:41 (初学一级) | 2012-07-24 13:55
0

这个功能最后启用了用脚本写的另外一个编辑器。这个为什么会出错的原因。可能是和我的项目哪有冲突。

wangming | 园豆:41 (初学一级) | 2012-07-25 14:47
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册