02-26-2016, 04:35 PM
(This post was last modified: 02-26-2016, 06:13 PM by wolfgang1983.)
My foreach loop picks up files and folders. But I am still having issue because when original_image is a folder it throws error.
I am not sure the best method of where to use if is file or a if is dir?
Because I use a input get as well.
Any suggestions?
Code:
A PHP Error was encountered
Severity: Notice
Message: Array to string conversion
Filename: controllers/Filemanager.php
Line Number: 204
Backtrace:
File: C:\wamp\www\project-2-upload\application\controllers\Filemanager.php
Line: 204
Function: _error_handler
File: C:\wamp\www\project-2-upload\application\controllers\Filemanager.php
Line: 91
Function: resize
File: C:\wamp\www\project-2-upload\index.php
Line: 292
I am not sure the best method of where to use if is file or a if is dir?
Because I use a input get as well.
Any suggestions?
PHP Code:
$this->load->helper('directory');
$get_directory = $this->input->get('directory');
if (isset($get_directory)) {
$cached_images = directory_map('./images/cache/' . $get_directory);
} else {
$cached_images = directory_map('./images/cache/catalog/');
}
foreach ($cached_images as $position => $image) {
$original_image = str_replace('_thumb-' . $width . 'x' . $height, '', $image);
$path = '';
if (isset($get_directory)) {
$path = '/' . $get_directory . '/' . $original_image;
} else {
$path = '/catalog/' . $original_image; // Line 204
}
var_dump(FCPATH . 'images'. $path);
}
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!