0
我使用codeigniter,我想讓elfinder的上傳路徑對每個id都是動態的。 我的文件夾層次結構是這樣的:elfinder設置動態上傳路徑
我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'文件夾下,但是當我嘗試上傳文件時,上傳的文件沒有出現在'提案'文件夾中。而是出現在根文件夾'mysite/proposal'中。所以它似乎elfinder無法讀取我的動態變量是路徑