I am using codeigniter, i want to make elfinder upload path to be dynamic for every id. my folder hierarchy is like this:
my elfinder opts :
$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);
}
this is my javascript calling 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>
the result is elfinder showing the right folder that i want which is under '(client_code)/proposal' folder, but when i try to upload file, the uploaded file is not appear in 'proposal' folder. instead appear in root folder 'mysite/proposal'. so it seems elfinder cannot read my dynamic variable to be path
ok, finally i can get this straight.. turns out that i just need to add 'requestType : POST', so elfinder can recognize the custom data.
<!-- 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');
});
The AJAX request type. Available choices are post and get.