01-20-2016, 02:20 AM
(This post was last modified: 01-20-2016, 03:58 AM by wolfgang1983.)
I have a small issue on my upload manager controller with my directory href .
How my upload manager bootstrap modal works. Once my modal is launched if there are any folders displayed I can click on them and then go inside that folder.
And if there is another sub folder I can also click on that and go into that folder.
Lest say where in the folder of banners: The problem is when I click on the sub folder in side banners the url href produces
It should in fact produce a url like below. Where it shows that parent folder.
I have two sections in my foreach loop one for images and one for directories.
In the foreach loop for directories href how can I make sure it will produce the correct url if in a sub folder?
Update
I have now added this code below to the is_dir foreach loop href
and produces the url below also but for some reason says %2F and not /
How my upload manager bootstrap modal works. Once my modal is launched if there are any folders displayed I can click on them and then go inside that folder.
And if there is another sub folder I can also click on that and go into that folder.
Lest say where in the folder of banners: The problem is when I click on the sub folder in side banners the url href produces
Code:
http://localhost/project/admin/common/upload/?directory=sub_folder
It should in fact produce a url like below. Where it shows that parent folder.
Code:
http://localhost/project/admin/common/upload/?directory=banners/sub_folder
I have two sections in my foreach loop one for images and one for directories.
In the foreach loop for directories href how can I make sure it will produce the correct url if in a sub folder?
PHP Code:
<?php
class Upload extends MX_Controller {
public function __construct() {
parent::__construct();
$this->load->model('admin/tool/model_tool');
}
public function index() {
if ($this->input->get('directory')) {
$directory = FCPATH . 'uploads/' . $this->input->get('directory') . '/';
} else {
$directory = FCPATH . 'uploads/';
}
$directories = glob($directory . '*', GLOB_ONLYDIR);
$data['images'] = array();
if (!$directories) {
$directories = array();
}
// Get files
$files = glob($directory . '*.{jpg,jpeg,png,gif,JPG,JPEG,PNG,GIF}', GLOB_BRACE);
if (!$files) {
$files = array();
}
// This makes it display folders and images so shows the current folders and images in Modal.
$images = array_merge($directories, $files);
foreach ($images as $image) {
$name = basename($image);
if (is_dir($image)) {
$data['images'][] = array(
'thumb' => '',
'name' => $name,
'type' => 'directory',
'path' => FCPATH . 'uploads/' . $name,
'href' => site_url('admin/common/upload') .'/?directory=' . $name
);
} elseif (is_file($image)) {
$data['images'][] = array(
'thumb' => $this->model_tool->resize_image($name, 100, 100),
'name' => $name,
'type' => 'image',
'path' => FCPATH . 'upload/' . $name,
'href' => ''
);
}
}
$data['parent'] = '';
$this->load->view('template/common/upload', $data);
}
}
I have now added this code below to the is_dir foreach loop href
Code:
'href' => site_url('admin/common/upload') .'/?directory=' . urlencode(substr($image, strlen(FCPATH . 'uploads/')))
and produces the url below also but for some reason says %2F and not /
Code:
http://localhost/riwakawebsitedesigns/admin/common/upload/?directory=banners%2Fsub_banners
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!