elfinder 设置动态上传路径
elfinder setting dynamic upload path
我正在使用 codeigniter,我想让 elfinder 上传路径对于每个 id 都是动态的。
我的文件夹层次结构是这样的:
我的 elfinder 选择:
$idce = $_GET['id_c'];
$client_code = $this->db->select('client_code')
->get_where('tb_clients', array('id_c' => $idce))
->row()
->client_code;
$tval = $this->db->select('tanggal_valuasi')
->get_where('tb_clients', array('id_c' => $idce))
->row()
->tanggal_valuasi;
$opts = array(
// 'debug' => true,
'roots' => array(
array(
'driver' => 'LocalFileSystem',
'path' => './upload/'.$client_code.'./proposal/',
'startPath' =>'./storage/'.$client_code.'./proposal/',
'URL' => site_url('storage').'/'.$client_code.'/'.'proposal/',
'attributes' => array(
array( // hide readmes
'pattern' => '/.quarantine'.'/',
// 'read' => false,
// 'write' => false,
'hidden' => true,
// 'locked' => false
) ,
array( // restrict access to png files
'pattern' => '/.tmb'.'/',
// 'read' => false,
// 'write' => false,
'hidden' => true,
// 'locked' => false
)
) ,
'uploadDeny' => array(
'text/php',
'text/x-php',
'application/php',
'application/x-php',
'application/x-httpd-php',
'application/x-httpd-php-source',
'text/html',
'text/css',
'text/js',
'application/js',
'application/x-javascript',
'application/javascript',
'application/ecmascript',
'text/javascript',
'text/ecmascript',
'application/octet-stream'
) ,
'disabled' => array(
'rename'
) ,
)
)
);
$this->load->library('elfinder_lib', $opts);
}
这是我的 javascript 呼叫 elfinder:
<script src="<?php echo base_url('asset/elfinder/js/elfinder.full.js');?>">
</script>
<!-- elFinder initialization (REQUIRED) -->
<script type="text/javascript" charset="utf-8">
$().ready(function() {
var elf = $('#elfinder').elfinder({
customData : {'id_c': document.getElementById('id_c').value},
defaultView : 'list',
url : '<?= base_url(); ?>admin/proposal_contract/elfinder_init',
`enter code here`// connector URL (REQUIRED)
uiOptions: {
toolbar : [
// toolbar configuration
['back', 'forward'],
['reload'],
['home', 'up'],
['upload'],
['open'],
['info'],
['copy', 'cut', 'paste'],
]
}
}).elfinder('instance');
});
</script>
结果是 elfinder 显示了我想要的正确文件夹,它位于“(client_code)/proposal”文件夹下,但是当我尝试上传文件时,上传的文件没有出现在 'proposal' 文件夹。而是出现在根文件夹 'mysite/proposal' 中。所以 elfinder 似乎无法将我的动态变量读取为 path
好吧,我终于可以说清楚了..
结果我只需要添加 'requestType : POST',这样 elfinder 就可以识别自定义数据了。
<!-- elFinder initialization (REQUIRED) -->
<script type="text/javascript" charset="utf-8">
$().ready(function() {
var elf = $('#elfinder').elfinder({
customData : {'id_c': document.getElementById('id_c').value},
defaultView : 'list',
requestType : post,
url : '<?= base_url(); ?>admin/proposal_contract/elfinder_init',
`enter code here`// connector URL (REQUIRED)
uiOptions: {
toolbar : [
// toolbar configuration
['back', 'forward'],
['reload'],
['home', 'up'],
['upload'],
['open'],
['info'],
['copy', 'cut', 'paste'],
]
}
}).elfinder('instance');
});
AJAX 请求类型。可用的选项有 post 和 get.
我正在使用 codeigniter,我想让 elfinder 上传路径对于每个 id 都是动态的。 我的文件夹层次结构是这样的:
我的 elfinder 选择:
$idce = $_GET['id_c'];
$client_code = $this->db->select('client_code')
->get_where('tb_clients', array('id_c' => $idce))
->row()
->client_code;
$tval = $this->db->select('tanggal_valuasi')
->get_where('tb_clients', array('id_c' => $idce))
->row()
->tanggal_valuasi;
$opts = array(
// 'debug' => true,
'roots' => array(
array(
'driver' => 'LocalFileSystem',
'path' => './upload/'.$client_code.'./proposal/',
'startPath' =>'./storage/'.$client_code.'./proposal/',
'URL' => site_url('storage').'/'.$client_code.'/'.'proposal/',
'attributes' => array(
array( // hide readmes
'pattern' => '/.quarantine'.'/',
// 'read' => false,
// 'write' => false,
'hidden' => true,
// 'locked' => false
) ,
array( // restrict access to png files
'pattern' => '/.tmb'.'/',
// 'read' => false,
// 'write' => false,
'hidden' => true,
// 'locked' => false
)
) ,
'uploadDeny' => array(
'text/php',
'text/x-php',
'application/php',
'application/x-php',
'application/x-httpd-php',
'application/x-httpd-php-source',
'text/html',
'text/css',
'text/js',
'application/js',
'application/x-javascript',
'application/javascript',
'application/ecmascript',
'text/javascript',
'text/ecmascript',
'application/octet-stream'
) ,
'disabled' => array(
'rename'
) ,
)
)
);
$this->load->library('elfinder_lib', $opts);
}
这是我的 javascript 呼叫 elfinder:
<script src="<?php echo base_url('asset/elfinder/js/elfinder.full.js');?>">
</script>
<!-- elFinder initialization (REQUIRED) -->
<script type="text/javascript" charset="utf-8">
$().ready(function() {
var elf = $('#elfinder').elfinder({
customData : {'id_c': document.getElementById('id_c').value},
defaultView : 'list',
url : '<?= base_url(); ?>admin/proposal_contract/elfinder_init',
`enter code here`// connector URL (REQUIRED)
uiOptions: {
toolbar : [
// toolbar configuration
['back', 'forward'],
['reload'],
['home', 'up'],
['upload'],
['open'],
['info'],
['copy', 'cut', 'paste'],
]
}
}).elfinder('instance');
});
</script>
结果是 elfinder 显示了我想要的正确文件夹,它位于“(client_code)/proposal”文件夹下,但是当我尝试上传文件时,上传的文件没有出现在 'proposal' 文件夹。而是出现在根文件夹 'mysite/proposal' 中。所以 elfinder 似乎无法将我的动态变量读取为 path
好吧,我终于可以说清楚了.. 结果我只需要添加 'requestType : POST',这样 elfinder 就可以识别自定义数据了。
<!-- elFinder initialization (REQUIRED) -->
<script type="text/javascript" charset="utf-8">
$().ready(function() {
var elf = $('#elfinder').elfinder({
customData : {'id_c': document.getElementById('id_c').value},
defaultView : 'list',
requestType : post,
url : '<?= base_url(); ?>admin/proposal_contract/elfinder_init',
`enter code here`// connector URL (REQUIRED)
uiOptions: {
toolbar : [
// toolbar configuration
['back', 'forward'],
['reload'],
['home', 'up'],
['upload'],
['open'],
['info'],
['copy', 'cut', 'paste'],
]
}
}).elfinder('instance');
});
AJAX 请求类型。可用的选项有 post 和 get.