Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在FCKeditor中动态更改图像上载路径_C#_Upload_Fckeditor - Fatal编程技术网

C# 如何在FCKeditor中动态更改图像上载路径

C# 如何在FCKeditor中动态更改图像上载路径,c#,upload,fckeditor,C#,Upload,Fckeditor,我正在使用ASP.NET二进制文件作为FCKeditor,需要在同一页上插入两个编辑器。上传的图片/浏览需要转到两个不同的目录,如何从代码隐藏中执行此操作 我知道上载文件的路径是在config.ascx-文件中用UserFilesPath设置的,但我找不到从我的aspx.cs文件中覆盖此值的方法 此外,我还发现了一些(相互矛盾的)文档,说明可以设置会话[“FCKeditor:userfilepath”],但我不喜欢将特定于用户控件的信息放在全局会话变量中。哦,亲爱的,经过很多努力,我唯一能得到的

我正在使用ASP.NET二进制文件作为FCKeditor,需要在同一页上插入两个编辑器。上传的图片/浏览需要转到两个不同的目录,如何从代码隐藏中执行此操作

我知道上载文件的路径是在
config.ascx
-文件中用
UserFilesPath
设置的,但我找不到从我的
aspx.cs
文件中覆盖此值的方法


此外,我还发现了一些(相互矛盾的)文档,说明可以设置
会话[“FCKeditor:userfilepath”]
,但我不喜欢将特定于用户控件的信息放在全局会话变量中。

哦,亲爱的,经过很多努力,我唯一能得到的是:

fckEditor1.Config

财产。尝试为要配置的编辑器设置它:


fckEditor1.Config[“userfilepath”]=“您的路径”

这可能会起作用。至少它对我有用

Session["FCKeditor:UserFilesPath"] = "~/images/";

抱歉,我认为您最好停止使用该控件,改用javascript api。

首先需要将用户身份信息分配到会话[“UserInfo”]

然后去 [fckeditor根文件夹]/filemanager/connector/aspx/config.ascx

string Userfolder=Session[“UserInfo”].ToString();
//用户文件的URL路径。

UserFilesPath=“~/Upload/”+Userfolder

完整主题:FCK editor 2.x:使用单个FCKeditor将$Config['UserFilePath']以安全的方式完全动态化,从而将文件/图像/视频上载到不同的文件夹中,用于不同的应用程序

这可以通过多种方式实现。我正在解释一个过程,我根据我的php应用程序的代码结构应用了这个过程。对于不同的应用程序,我遵循相同的代码结构/框架,每个应用程序都是我服务器中的一个子文件夹。因此,在逻辑上需要使用一个FCKeditor,并以某种方式对其进行配置,以使其能够对所有应用程序正常工作。FCKeditor的内容部分正常。它可以很容易地被来自单个FCKeditor组件的不同应用程序或项目重用。但问题出现在文件上传上,比如图像、视频或任何其他文档。为了使其适用于不同的项目,必须将文件上载到不同项目的separe文件夹中。对于$Config['userfilepath']必须配置为动态文件夹路径,这意味着每个项目的文件夹路径不同,但在同一位置调用相同的FCKeditor组件。我正在一步一步地解释一些不同的过程。那些在FCKeditor 2.5.1版和VersionBuild 17566版中对我起到了很好的作用,我希望它们也能对其他人起到作用。如果它不适用于其他开发人员,那么他们可能需要根据项目代码结构和文件夹写入权限以及FCKeditor版本在这些过程中进行一些调整

1) 在fckeditor\editor\filemanager\connectors\phpconfig.php文件中

a) 追求全局$Config;$Config['Enabled']=false; i) 在这里,如果需要依赖于会话的安全方法:仅用于单个站点设置:即,每个项目域或子域有一个FCKeditor,而不是多个项目有一个FCKeditor,则放置以下代码:

if(!isset($_SESSION)){
session_start(); 
}

if(isset($_SESSION['SESSION_SERVER_RELATIVEPATH']) && $_SESSION['SESSION_SERVER_RELATIVEPATH']!="") { 
$relative_path=$_SESSION['SESSION_SERVER_RELATIVEPATH']; 
include_once($_SERVER['DOCUMENT_ROOT'].$relative_path."configurations/configuration.php");
}
if(isset($_REQUEST['param_project_to_fck']) && $_REQUEST['param_project_to_fck']!=""){ //base64 encoded relative folder path of the project corresponding to the webroot; should be like "/project/folder/path/" before encoding 
$relative_path=base64_decode($_REQUEST['param_project_to_fck']);
include_once($_SERVER['DOCUMENT_ROOT'].$relative_path."configurations/configuration.php");
}
// Path to user files relative to the document root.
$Config['UserFilesPath'] = '/userfiles/' ;
注意:此处,$\u SESSION['SESSION\u SERVER\u RELATIVEPATH']:对应于webroot的项目的相对文件夹路径;应类似于“/project/folder/path/”,并在启动会话的项目中的公共文件中设置此会话变量。项目中应该有一个configurations/configuration.php作为配置文件。如果名称或路径不同,则必须在此处放置相应的路径,而不是configurations/configuration.php

ii)如果希望为不同的项目使用单个FCKeditor组件(表示为不同的子文件夹)并采用会话相关的安全方式(假设不同项目的会话名称不同,以区分其在单个服务器中的会话)。但是,如果项目表示为子域或不同的域,则必须使用下面提供的会话独立方式(iii)(尽管不安全),那么它将不起作用。放置此代码:

if(!isset($_SESSION)){
session_name($_REQUEST['param_project_to_fck']); 
session_start(); 
}

if(isset($_SESSION['SESSION_SERVER_RELATIVEPATH']) && $_SESSION['SESSION_SERVER_RELATIVEPATH']!="") { 
$relative_path=$_SESSION['SESSION_SERVER_RELATIVEPATH']; 
include_once($_SERVER['DOCUMENT_ROOT'].$relative_path."configurations/configuration.php");
}
请阅读上一点末尾的注意事项,即第(i)点

iii)如果希望为不同的项目使用单个FCKeditor组件,则表示不同的子文件夹以及子域或域(尽管它不是完全安全的)。放置此代码:

if(!isset($_SESSION)){
session_start(); 
}

if(isset($_SESSION['SESSION_SERVER_RELATIVEPATH']) && $_SESSION['SESSION_SERVER_RELATIVEPATH']!="") { 
$relative_path=$_SESSION['SESSION_SERVER_RELATIVEPATH']; 
include_once($_SERVER['DOCUMENT_ROOT'].$relative_path."configurations/configuration.php");
}
if(isset($_REQUEST['param_project_to_fck']) && $_REQUEST['param_project_to_fck']!=""){ //base64 encoded relative folder path of the project corresponding to the webroot; should be like "/project/folder/path/" before encoding 
$relative_path=base64_decode($_REQUEST['param_project_to_fck']);
include_once($_SERVER['DOCUMENT_ROOT'].$relative_path."configurations/configuration.php");
}
// Path to user files relative to the document root.
$Config['UserFilesPath'] = '/userfiles/' ;
请阅读第(i)点末尾的注意事项

b) 现在,对于您选择的任何案例,请查找以下代码:

if(!isset($_SESSION)){
session_start(); 
}

if(isset($_SESSION['SESSION_SERVER_RELATIVEPATH']) && $_SESSION['SESSION_SERVER_RELATIVEPATH']!="") { 
$relative_path=$_SESSION['SESSION_SERVER_RELATIVEPATH']; 
include_once($_SERVER['DOCUMENT_ROOT'].$relative_path."configurations/configuration.php");
}
if(isset($_REQUEST['param_project_to_fck']) && $_REQUEST['param_project_to_fck']!=""){ //base64 encoded relative folder path of the project corresponding to the webroot; should be like "/project/folder/path/" before encoding 
$relative_path=base64_decode($_REQUEST['param_project_to_fck']);
include_once($_SERVER['DOCUMENT_ROOT'].$relative_path."configurations/configuration.php");
}
// Path to user files relative to the document root.
$Config['UserFilesPath'] = '/userfiles/' ;
并替换以下代码:

if(isset($SERVER_RELATIVEPATH) &&  $SERVER_RELATIVEPATH==$relative_path) { //to make it relatively secure so that hackers can not create any upload folder automatcally in the server, using a direct link and can not upload files there 
$Config['Enabled'] = true ;
$file_upload_relative_path=$SERVER_RELATIVEPATH;
}else{
$Config['Enabled'] = false ;
exit();
}
// Path to user files relative to the document root.
//$Config['UserFilesPath'] = '/userfiles/' ;
//$Config['UserFilesPath'] = $file_upload_relative_path.'userfiles/' ;
$Config['UserFilesPath'] = '/userfiles'.$file_upload_relative_path;
此处$SERVER_RELATIVEPATH是相对路径,必须在前面包含的项目配置文件中进行设置

在这里,您可以使用$file\u upload\u relative\u path变量将$Config['UserFilesPath']与任何其他动态文件夹路径一起设置。在my bluehost linux服务器中,由于项目根文件夹(0755权限)与其下的userfiles文件夹以及userfiles下的子文件夹之间存在文件夹用户权限冲突,因此(根据FCKeditor编码应为0777),因此不允许上载这些文件夹中的文件。因此,我在服务器webroot(项目根文件夹之外)创建了一个文件夹userfiles,并将权限设置为0777,使用$config设置的代码如下:

$Config['UserFilesPath'] = '/userfiles'.$file_upload_relative_path; 
但是,如果您对案例中项目子文件夹的写入权限没有问题,则可以使用前一行(在前一代码段中注释掉):

请注意,如果文件中的现有$Config['userfilepath']='/userfiles/';存在于文件的其他位置,则可以通过替换或简单注释将其注释掉

2) 如果选择1)(a)(ii)或(iii)方法,则打开
(a) fckeditor\editor\filemanager\browser\default\browser.html文件

搜索此行:var sConnUrl=GetUrlParam('Connector')

将以下命令放在该行之后:

var param_project_to_fck = GetUrlParam( 'param_project_to_fck' ) ; 
现在,搜索这一行:sUr