阿土仔的世界
教师博客
首页
新随笔
联系
聚合
管理
随笔-8 评论-30 文章-0 trackbacks-0
.Net下FCKEditor按照不同用户自动设置不同浏览上传目录的实现
By:tzz
此设置方法通用于Image,Flash和Link类的浏览目录。这里所说的浏览上传目录指的是在点击Flash或者Image或者Link按钮时,选择“浏览服务器”时的初始目录,下文称之为用户文件目录。我们现在要实现的,就是将用户文件目录根据用户的不同而改变。比如我根据用户ID来建立文件夹来为用户提供上传服务。则ID=1的用户,其用户文件目录就是...../1/,而ID=2的用户,其用户文件目录就是...../2/。有点啰嗦,
。下文我就根据用户ID来设置用户文件目录。
首先我们来分析FckEditor是如何来确定用户文件目录的。我们来看看FckEditor设置用户文件目录的代码。
protected
string
UserFilesPath
{
get
{
if
( sUserFilesPath
==
null
)
{
//
Try to get from the "Application".
sUserFilesPath
=
(
string
)Application[
"
FCKeditor:UserFilesPath
"
] ;
//
Try to get from the "Session".
if
( sUserFilesPath
==
null
||
sUserFilesPath.Length
==
0
)
{
sUserFilesPath
=
(
string
)Session[
"
FCKeditor:UserFilesPath
"
] ;
//
Try to get from the Web.config file.
if
( sUserFilesPath
==
null
||
sUserFilesPath.Length
==
0
)
{
sUserFilesPath
=
System.Configuration.ConfigurationSettings.AppSettings[
"
FCKeditor:UserFilesPath
"
] ;
//
Otherwise use the default value.
if
( sUserFilesPath
==
null
||
sUserFilesPath.Length
==
0
)
sUserFilesPath
=
DEFAULT_USER_FILES_PATH ;
//
Try to get from the URL.
if
( sUserFilesPath
==
null
||
sUserFilesPath.Length
==
0
)
{
sUserFilesPath
=
Request.QueryString[
"
ServerPath
"
] ;
}
}
}
//
Check that the user path ends with slash ("/")
if
(
!
sUserFilesPath.EndsWith(
"
/
"
) )
sUserFilesPath
+=
"
/
"
;
//
add by tzz for multiuser
//
sUserFilesPath = sUserFilesPath + Session["user_id"].ToString() + "/" ;
}
return
sUserFilesPath ;
}
}
可以看到,FckEditor是从“UserFilesPath”来获取用户文件目录的。我们可以看到FckEditor取UserFilesPath的顺序为:Application["FCKeditor:UserFilesPath"] -->Session["FCKeditor:UserFilesPath"]--->System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"]-->默认值。Application、web.config都是全局的,我们不用,所以我们的目标就是通过设置Session["FCKeditor:UserFilesPath"]来根据不同的用户设置不同的用户文件目录。可能会有朋友问,为什么不直接引用Solution中的Session,比如自己的webapplication中的Session[UserID],然后直接在上述代码里修改,比如加入:
sUserFilesPath
=
sUserFilesPath
+
Session[
"
user_id
"
].ToString()
+
"
/
"
;
这是行不通的。
Session不能在两个不同的应用程序之间传递!
接下来的问题就在于在哪里改变Session["FCKeditor:UserFilesPath"]。这里很重要。切忌,
要在“~\FCKeditor\editor\filemanager\browser\default\connectors\aspx\connector.aspx”的OnInit事件中设定
,而不能在Page_Load事件中设定。上文说过我们不能通过使用启动工程中的Session,那我们如果得到用户的ID呢?对,通过url的参数。为了实现通过url传递有关用户ID的参数,我们就必须在使用FckEditor的页面增加如下代码,设置ImageBrowserURL、LinkBrowserURL、FlashBrowserURL的值:
string
sImageBrowserURL
=
"
/demo/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/aspx/connector.aspx&UserID=
"
+
user_id.ToString();
string
sFlashBrowserURL
=
"
/demo/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/aspx/connector.aspx&UserID=
"
+
user_id.ToString();
string
sLinkBrowserURL
=
"
/demo/FCKeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/aspx/connector.aspx&UserID=
"
+
user_id.ToString();
FCKeditor_diary.ImageBrowserURL
=
sImageBrowserURL;
FCKeditor_diary.LinkBrowserURL
=
sLinkBrowserURL;
FCKeditor_diary.FlashBrowserURL
=
sFlashBrowserURL;
其中,“demo”是你的应用程序。现在我们可以在connector.aspx的OnInit事件中加代码了:
<
script runat
=
"
server
"
language
=
"
C#
"
>
protected
override
void
OnInit(EventArgs e)
{
if
(Request.QueryString[
"
UserID
"
]
==
null
)
{
Session[
"
FCKeditor:UserFilesPath
"
]
=
"
~/uploaded/
"
;
//
设置默认值
}
else
{
Session[
"
FCKeditor:UserFilesPath
"
]
=
"
~/uploaded/
"
+
Request.QueryString[
"
UserID
"
]
+
"
/
"
;
}
}
</
script
>
然后编译,运行。该方法不用修改FckEditor的源文件,感觉还是比较简单的。
posted on 2006-11-18 15:53
阿土仔的世界
阅读(1336)
评论(8)
编辑
收藏
引用
网摘
所属分类:
DotNET
评论:
#
re: .Net下FCKEditor按照不同用户自动设置不同浏览上传目录的实现 2007-06-22 16:57 |
AAA
Session["FCKeditor:UserFilesPath"] 在使用它的页面的OnInit里设置就可以了.所以,就不需要Request传递USERID了.呵 呵.
回复
更多评论
#
re: .Net下FCKEditor按照不同用户自动设置不同浏览上传目录的实现 2007-07-29 11:51 |
钻石
http://www.hoopower.com
收录
回复
更多评论
#
re: .Net下FCKEditor按照不同用户自动设置不同浏览上传目录的实现 2007-08-23 12:20 |
searover
用request传? 那如果我知道你的id,那我不就可以看到你上传的文件了吗?
回复
更多评论
#
re: .Net下FCKEditor按照不同用户自动设置不同浏览上传目录的实现 2007-08-23 12:21 |
searover
这个安全性还是要判断的了
回复
更多评论
#
re: .Net下FCKEditor按照不同用户自动设置不同浏览上传目录的实现 2007-12-19 05:10 |
dfhdfh
http://ospitale-sesso-vicenza.pensano-cho.info
http://madri-vogliose.pensano-cho.info
http://festa-donna-sesso-foto.pensano-cho.info
http://foto-ragazzi-completamente-nudi.pensano-cho.info
http://webcam-videochat.com.es-foto-dr-travesti.solosessoit-usl.info
http://sexe-free-movies.arrapata-usl.info
http://vieille-pute-lyon.3554-usl.info
http://puttana-film-amatoriale.fotoporno-vfl.info
http://sexe-sur-msn.solosessoit-usl.info
http://vieille-and-mamie-and-salope.arrapata-usl.info
http://xxx-free-long-movie.pensano-cho.info
http://racconto-sesso-gay.pensano-cho.info
http://giovane-nuda-arrapata.pensano-cho.info
http://racconto-peretta-clistere.pensano-cho.info
http://comment-te-baiser.ristrutturare-usl.info
http://site-cul-plus-visiter-france.3554-usl.info
http://sexe-video-clip.ristrutturare-usl.info
http://sesso-figa-foto-gratis.pensano-cho.info
http://pute-web-gratuit.ristrutturare-usl.info
http://photo-sexe-homme-femme.ristrutturare-usl.info
http://petite-femme-salope.ristrutturare-usl.info
http://video-porno-completo-gratis.pensano-cho.info
http://porno-cavallo-com.pensano-cho.info
http://photo-femme-sexe-enceinte-gross-gratuite.3554-usl.info
http://video-negra-troia-gratis.fotoporno-vfl.info
http://sesso-storia-vere-coppia.pensano-cho.info
http://nique-le-psg.minchia-usl.info
回复
更多评论
#
re: .Net下FCKEditor按照不同用户自动设置不同浏览上传目录的实现 2007-12-23 08:16 |
scscs
http://branler-les-sein.denrico-elb.info
http://video-comment-sucer-bite-entre-bite.denrico-elb.info
http://photo-and-de-and-cul.vagine-elb.info
http://faint-ragazza-inculata.asiannudes-tun.info
http://belle-chatte-copine.vagine-elb.info
http://vibromasseur-vibro.denrico-elb.info
http://femme-qui-baise-homme.lexington-elb.info
http://fetish-nylon.teresa-tun.info
http://journal-intime-blog-sexe.denrico-elb.info
http://sexe-extrait-gratuit-film.vagine-elb.info
http://it-gothic-xxx.teresa-tun.info
http://gratuit-sexe-film.lexington-elb.info
http://bonne-salope.gem-elb.info
http://50-cent-lil-bite.lexington-elb.info
http://beurette-sexe-font.lexington-elb.info
http://skyblog-film-sexe.lexington-elb.info
http://j-ai-belle-bite.gem-elb.info
http://pisello-dei-maschio-nudo.teresa-tun.info
http://chatte-tera-patrick.vagine-elb.info
http://photo-de-bite-noir.denrico-elb.info
http://buchi-di-culo-sfondati.asiannudes-tun.info
http://amatoriali-nudi-gratis.teresa-tun.info
http://sexe-bicasse-blacke-anal.lexington-elb.info
http://trou-cul-mec-dilate.lexington-elb.info
http://photo-chatte-poilue-amatrice.lexington-elb.info
http://recit-deshabille-bite.vagine-elb.info
http://sexe-traceur.gem-elb.info
回复
更多评论
#
re: .Net下FCKEditor按照不同用户自动设置不同浏览上传目录的实现 2007-12-30 08:36 |
dfhdfh
http://sesso-gratis-movie-ragazze.gradis-tun.info
http://tv-sexe-forum.culs-ugx.info
http://donna-fanno-sesso-cavallo-cane.fatte-tun.info
http://salope-sexe-exhibe.succhiano-ugx.info
http://porno-reggicalza-gratis.fatte-tun.info
http://sexe-japonaise-photo.culs-ugx.info
http://fighe-pelose-celebrita-gratis.fatte-tun.info
http://femme-aime-cul.succhiano-ugx.info
http://video-gratis-porno-anale.sculaccia-tun.info
http://veut-cul-com-gratuis.senegalese-ugx.info
http://chiavata-video.gradis-tun.info
http://sexe-clip-gratuit-lesbienne.culs-ugx.info
http://porno-super.gradis-tun.info
http://sexe-lieu.culs-ugx.info
http://negro-gigante.sculaccia-tun.info
http://jeu-adulte-sexe.senegalese-ugx.info
http://fucked-matura-movie.fatte-tun.info
http://travesti-soumise-black.succhiano-ugx.info
http://foto-sexy-monica-bellucci.gradis-tun.info
http://petite-salope-mini-jupe.culs-ugx.info
http://gotiche-hard-sesso-diciottenne.sculaccia-tun.info
http://dvd-baise.senegalese-ugx.info
http://inurl-category-inurl-fetish-intitle-video.sculaccia-tun.info
http://sexe-string-cul-chatte.senegalese-ugx.info
http://moglie-racconto.fatte-tun.info
http://extrait-film-cul.senegalese-ugx.info
http://justine-porno-star.gradis-tun.info
http://grosse-bite-porno-photo.culs-ugx.info
http://rubinetto-fontana-acqua-calda-fredda.gradis-tun.info
http://liste-site-rencontre-sexe.succhiano-ugx.info
http://cazzo-fica-xxx-porno.gradis-tun.info
http://ai-encule.senegalese-ugx.info
http://matura-pompinare-com.gradis-tun.info
http://gay-pisse-cul.succhiano-ugx.info
http://foto-vip-nuda-nudo.fatte-tun.info
http://pute-a-vannes.senegalese-ugx.info
http://sesso-uomo-uomo.fatte-tun.info
回复
更多评论
#
re: .Net下FCKEditor按照不同用户自动设置不同浏览上传目录的实现
2008-04-23 17:28 |
m_ptrReality
支持AAA的说法,直接在使用FCKEditor的页面里面设置
Session["FCKeditor:UserFilesPath"]="XXX"
就可以了
回复
更多评论
刷新评论列表
只有注册用户
登录
后才能发表评论, 未注册用户请先
注册
。
网站导航:
博客园
BlogJava
博客生活
IT博客网
C++博客
PHP博客
博客园社区
管理博客
教师博客
天文博客
汽车博客
足球博客
股票博客
电子博客
第二次实验报告请在11月19日之前上交至FTP。 FTP地址:10.161.250.1:6688。 文件名格式:学号_姓名_实验次数.doc。 例如:小红同学的第一次实验报告的文件名为:11111111_小红_1.doc
<
2008年4月
>
日
一
二
三
四
五
六
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
留言簿
(6)
给我留言
查看公开留言
查看私人留言
随笔分类
DotNET(1)
网络编程(7)
网络技术
随笔档案
2006年11月 (8)
文章分类
DotNET
网络编程
搜索
最新评论
1. re: [实验指导]C#网络编程实验一:DNS协议开发
谢谢这位老师,这种交流方式值得学习
--果丹皮
2. re: .Net下FCKEditor按照不同用户自动设置不同浏览上传目录的实现
评论内容较长,点击标题查看
--m_ptrReality
3. re: [实验指导]C#网络编程实验二:聊天室的开发
评论内容较长,点击标题查看
--kwl
4. re: .Net下FCKEditor按照不同用户自动设置不同浏览上传目录的实现
评论内容较长,点击标题查看
--dfhdfh
5. re: .Net下FCKEditor按照不同用户自动设置不同浏览上传目录的实现
评论内容较长,点击标题查看
--scscs
阅读排行榜
1. Visual C# HTTP协议开发(3951)
2. [课件]第四章:Visual C# FTP编程(2902)
3. [实验指导]C#网络编程实验二:聊天室的开发(1600)
4. [课件]第三章:Visual C#TCP协议编程(1413)
5. .Net下FCKEditor按照不同用户自动设置不同浏览上传目录的实现(1336)
评论排行榜
1. [实验指导]C#网络编程实验二:聊天室的开发(8)
2. .Net下FCKEditor按照不同用户自动设置不同浏览上传目录的实现(8)
3. [课件]第四章:Visual C# FTP编程(4)
4. Visual C# HTTP协议开发(3)
5. [课件]第三章:Visual C#TCP协议编程(3)