我正在使用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显示了我想要的正确文件夹,其中包含&#39;(client_code)/ proposal&#39;文件夹,但是当我尝试上传文件时,上传的文件不会出现在&#39;提案&#39;夹。而是出现在根文件夹&#39; mysite / proposal&#39;中。所以似乎elfinder无法将我的动态变量读成路径
答案 0 :(得分:0)
<!-- 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请求类型。可用的选择是发布和获取。