麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

實現FCKeditor 多用戶分文件夾上傳圖片等附件

2019-11-17 04:27:33
字體:
來源:轉載
供稿:網友

  FCKeditor在web.config中有多項設置:view plaincopy to clipboardPRint?
<appSettings> 
<!--FCKeditor設置(主要是以下兩項)--> 
<!--FCKeditor編輯器路徑--> 
<add key="FCKeditor:BasePath" value="/FCKeditor/"/> 
<!--FCKeditor用戶附件上傳路徑--> 
<add key="FCKeditor:UserFilesPath" value="/Resources/TempUpload/"/> 
</appSettings> 

 <appSettings>
 <!--FCKeditor設置(主要是以下兩項)-->
 <!--FCKeditor編輯器路徑-->
 <add key="FCKeditor:BasePath" value="/FCKeditor/"/>
 <!--FCKeditor用戶附件上傳路徑-->
 <add key="FCKeditor:UserFilesPath" value="/Resources/TempUpload/"/>
 </appSettings>  用戶登錄后通過FCKeditor上傳文件則要放置在用戶共用上傳路徑“/Resources/UserUpload/”+“用戶郵箱地址”,如“/Resources/UserUpload/user@Gmail.com”。FCKeditor.net獲取上傳路徑文件是:FileWorkerBase.cs,打開找到以下部分view plaincopy to clipboardprint?
 protected string UserFilesPath  
    {  
      get 
      {  
        if ( sUserFilesPath == null )  
        {  
          // 第一回從application["FCKeditor:UserFilesPath"] 中讀取,如果沒有嘗試其它方式  
          sUserFilesPath = (string)Application["FCKeditor:UserFilesPath"] ;  
 
          // 第二回從session["FCKeditor:UserFilesPath"] 中讀取,如果沒有嘗試其它方式  
          if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )  
          {  
            sUserFilesPath = (string)Session["FCKeditor:UserFilesPath"] ;  
              
            // 第三回從web.config中讀取,如果沒有嘗試其它方式  
            if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )  
            {  
              sUserFilesPath = System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"] ;  
                
              // 第四回從DEFAULT_USER_FILES_PATH(這個變量在同文件中)中讀取,如果沒有嘗試其它方式  
              if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )   
                sUserFilesPath = DEFAULT_USER_FILES_PATH ;  
 
              // 第五回從網址參數ServerPath中讀取  
              if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )   
              {  
                sUserFilesPath = Request.QueryString["ServerPath"] ;  
              }  
 
            }  
          }  
 
          // Check that the user path ends with slash ("/")  
          if ( ! sUserFilesPath.EndsWith("/") )  
            sUserFilesPath += "/" ;  
        }  
        return sUserFilesPath ;  
      }  
    } 

 protected string UserFilesPath
    {
      get
      {
        if ( sUserFilesPath == null )
        {
          // 第一回從Application["FCKeditor:UserFilesPath"] 中讀取,如果沒有嘗試其它方式
          sUserFilesPath = (string)Application["FCKeditor:UserFilesPath"] ;

          // 第二回從Session["FCKeditor:UserFilesPath"] 中讀取,如果沒有嘗試其它方式
          if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
          {
            sUserFilesPath = (string)Session["FCKeditor:UserFilesPath"] ;
           
            // 第三回從web.config中讀取,如果沒有嘗試其它方式
            if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
            {
              sUserFilesPath = System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"] ;
             
              // 第四回從DEFAULT_USER_FILES_PATH(這個變量在同文件中)中讀取,如果沒有嘗試其它方式
              if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
                sUserFilesPath = DEFAULT_USER_FILES_PATH ;

              // 第五回從網址參數ServerPath中讀取
              if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )
              {
                sUserFilesPath = Request.QueryString["ServerPath"] ;
              }

            }
          }

          // Check that the user path ends with slash ("/")
          if ( ! sUserFilesPath.EndsWith("/") )
            sUserFilesPath += "/" ;
        }
        return sUserFilesPath ;
      }
    }  從上面的注釋可以看到用戶上傳路徑的順序,只要在頁面加載的時候設置下Session["FCKeditor:UserFilesPath"]就可以設置FCKeditor上用戶上傳路徑了view plaincopy to clipboardprint?
protected void Page_Load(object sender, EventArgs e)  
{  
 if (!Page.IsPostBack)  
 Session["FCKeditor:UserFilesPath"] = "用戶上傳路徑";  

protected void Page_Load(object sender, EventArgs e)
{
 if (!Page.IsPostBack)
 Session["FCKeditor:UserFilesPath"] = "用戶上傳路徑";
}  (我在配置的時候關閉了文件瀏覽,只提供文件快速上傳)但是在使用的時候如果“Resources/UserUpload/[email protected]”中的[email protected]路徑沒創建,上傳中FCKeditor它不會創建,也導致了文件無法上傳成功,那就需要再修改FCKeditor.net項目中的Uploader.cs文件,添加一段文件夾存在的檢測代碼,如果不存在用戶指定的文件夾側創建一個view plaincopy to clipboardprint?
// Get the uploaded file name.  
string sFileName = System.IO.Path.GetFileName( oFile.FileName ) ;  
 
int iCounter = 0 ;  
 
//景裔添加  
//檢查上傳目錄是否已經被創建  
//開始==========================================  
//檢查當前完整路徑是否存在,不存在則開始逐級輪詢檢查,不存則就創建  
if (!System.IO.Directory.Exists(UserFilesDirectory))  
{  
string[] tempDirectorys = UserFilesDirectory.Split(new string[] { "http://" }, StringSplitOptions.RemoveEmptyEntries); 
string tempDirectory = string.Empty; 
for (int i = 0; i < tempDirectorys.Length; i++) 

tempDirectory += tempDirectorys[i] + "http://"; 
if (!System.IO.Directory.Exists(tempDirectory)) 
System.IO.Directory.CreateDirectory(tempDirectory); 


//結束========================================== 
 
while ( true ) 

string sFilePath = System.IO.Path.Combine( this.UserFilesDirectory, sFileName ) ; 
 
if ( System.IO.File.Exists( sFilePath ) ) 

iCounter++ ; 
sFileName =  
System.IO.Path.GetFileNameWithoutExtension( oFile.FileName ) + 
"(" + iCounter + ")" +  
System.IO.Path.GetExtension( oFile.FileName ) ;  
 
iErrorNumber = 201 ;  
}  
else 
{  
oFile.SaveAs( sFilePath ) ;  
 
sFileUrl = this.UserFilesPath + sFileName ;  
break ;  
}  

 // Get the uploaded file name.
 string sFileName = System.IO.Path.GetFileName( oFile.FileName ) ;

 int iCounter = 0 ;

 //景裔添加
 //檢查上傳目錄是否已經被創建
 //開始==========================================
 //檢查當前完整路徑是否存在,不存在則開始逐級輪詢檢查,不存則就創建
 if (!System.IO.Directory.Exists(UserFilesDirectory))
 {
 string[] tempDirectorys = UserFilesDirectory.Split(new string[] { "http://" }, StringSplitOptions.RemoveEmptyEntries);
 string tempDirectory = string.Empty;
 for (int i = 0; i < tempDirectorys.Length; i++)
 {
 tempDirectory += tempDirectorys[i] + "http://";
 if (!System.IO.Directory.Exists(tempDirectory))
 System.IO.Directory.CreateDirectory(tempDirectory);
 }
 }
 //結束==========================================

 while ( true )
 {
 string sFilePath = System.IO.Path.Combine( this.UserFilesDirectory, sFileName ) ;

 if ( System.IO.File.Exists( sFilePath ) )
 {
 iCounter++ ;
 sFileName =
 System.IO.Path.GetFileNameWithoutExtension( oFile.FileName ) +
 "(" + iCounter + ")" +
 System.IO.Path.GetExtension( oFile.FileName ) ;

 iErrorNumber = 201 ;
 }
 else
 {
 oFile.SaveAs( sFilePath ) ;

 sFileUrl = this.UserFilesPath + sFileName ;
 break ;
 }
 }  這樣就基本解決了多用戶分文件夾上傳圖片的問題,不過也有缺陷的地方,就是當用戶Session超時的時候,用戶再使用瀏覽器上傳文件就不會按照指定用戶文件夾上傳來了,分析這個情況可以得出:這個時候用戶通過編輯器上傳的文件也就是對編輯器內容作出了修改,但是因為Session超時了,所以可以把做出的修改視作無效,既然修改無效,那用戶上傳的文件也是沒用的,所在我在web.config中又設置了個默認文件上傳位置,所有無效文件都會上傳到這里,那個回清理的時候也方便多了  不知道哪位大蝦還有更好的辦法。
出處:http://blog.breakn.net/article.asp?id=388


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 精品久久久久久久久久久久包黑料 | 久久久国产精品成人免费 | 在线观看免费污视频 | 精品国产一区二区三区在线观看 | 午夜视频在线免费观看 | av久草 | 欧美一区二区片 | 久久不射电影 | 国产成人强伦免费视频网站 | 欧美精品免费一区二区三区 | 狠狠操电影 | 久久经典国产视频 | hd porn 4k video xhicial| 亚洲人成在线播放网站 | 久久国产一级片 | 爱操av| 99影视在线视频免费观看 | 一区二区久久精品66国产精品 | 国内精品伊人久久 | 高清国产在线 | 老a影视网站在线观看免费 国产精品久久久久久久久久尿 | 国产大片全部免费看 | 麻豆国产一区 | 色天使中文字幕 | 一日本道久久久精品国产 | 亚洲综合精品 | 牛牛碰在线 | 国产理论视频在线观看 | 成人av一二三区 | 午夜精品影院 | 久久久久久片 | 欧美一级小视频 | 欧美日韩中文字幕在线视频 | 亚洲电影免费观看国语版 | 国产毛片在线 | 国产免费福利视频 | 一分钟免费观看完整版电影 | 一级大片一级一大片 | 精品一区二区三区中文字幕 | 毛片免费在线播放 | 久久久www成人免费精品 |