Hi all, I have been working on a function where can create a folder on my file manger, using mkdir.
I would like to know does codeigniter have a helper for that I know the have a helper for creating files but have not see one for creating directories
PHP Code:
public function folder() {
$json = array();
$directory = FCPATH . 'image/catalog/' . $this->input->get('directory');
if (is_dir($directory)) {
mkdir($directory . '/' . $this->input->post('folder'), 0777);
$json['success'] = 'The folder ' . $this->input->post('folder') . 'was created!';
} else {
$json['error'] = 'The folder ' . $this->input->post('folder') . 'was not created!';
}
$this->output->set_content_type('Content-Type: application/json');
$this->output->set_output(json_encode($json));
}
Code:
<!-- Create Folder -->
<script type="text/javascript">
$('#button-folder').popover({
html: true,
placement: 'bottom',
trigger: 'click',
title: 'New Folder',
content: function() {
html = '<div class="input-group">';
html += ' <input type="text" name="folder" value="" placeholder="New Folder" class="form-control">';
html += ' <span class="input-group-btn"><button type="button" title="" id="button-create" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></span>';
html += '</div>';
return html;
}
});
$('#button-folder').on('shown.bs.popover', function() {
$('#button-create').on('click', function() {
$.ajax({
url: 'admin/common/filemanager/folder/?directory=<?php echo $directory; ?>',
type: 'post',
dataType: 'json',
data: 'folder=' + encodeURIComponent($('input[name=\'folder\']').val()),
beforeSend: function() {
$('#button-create').prop('disabled', true);
},
complete: function() {
$('#button-create').prop('disabled', false);
},
success: function(json) {
if (json['error']) {
alert(json['error']);
}
if (json['success']) {
alert(json['success']);
$('#button-refresh').trigger('click');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
});
</script>
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!