Welcome Guest, Not a member yet? Register   Sign In
Vairable Question
#1

(This post was last modified: 04-15-2015, 06:26 AM by wolfgang1983.)

Hello

I have a function and its called delete. When i delete my file it deletes it from two places, image/cache and another the saved cached image displays like a&t_logo-100x100.jpg 100x100 means width and height.

currently on this line $cached_image = FCPATH . 'image/cache/' . utf8_substr($path, 0, utf8_strrpos($path, '.')) . '-' . 100 . 'x' . 100 . '.' . $extension;

I have to enter the width and height manually.

I would like to be able to do this $width & $height replacing the manually entered width and height.

$cached_image = FCPATH . 'image/cache/' . utf8_substr($path, 0, utf8_strrpos($path, '.')) . '-' . $width . 'x' . $height . '.' . $extension;

How can I make it so when I enter in $width & $height variables that it would pick width and height up automatic.

utf8 is a custom helper that's autoloaded

PHP Code:
<?php

class File extends MX_Controller {
    public function 
delete() {
        
$json = array();

        if (!
$json) {
            
$path_post $this->input->post('path');
            if (isset(
$path_post)) {
                foreach (
$path_post as $path) {
                    
                    
unlink(FCPATH '/image/' $path);
                    
                    
rmdir(FCPATH '/image/' $path);
                    
                    
$extension pathinfo($pathPATHINFO_EXTENSION);

                    
//$cached_image = FCPATH . 'image/cache/' . utf8_substr($path, 0, utf8_strrpos($path, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
                    
                    
$cached_image FCPATH 'image/cache/' utf8_substr($path0utf8_strrpos($path'.')) . '-' 100 'x' 100 '.' $extension;    
    
                    
unlink($cached_image);
                }
            }

            foreach (
$path_post as $path) {
                
$json['success'] = $this->lang->line('text_delete');
            }
        }

        
$this->output->set_content_type('Content-Type: application/json');
        
$this->output->set_output(json_encode($json));
    }



In stead of having the width and height in image name should I just have it normal a&t_logo.jpg That I can do what would your thoughts be on that?
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
Vairable Question - by wolfgang1983 - 04-15-2015, 03:59 AM
RE: Vairable Question - by CroNiX - 04-15-2015, 07:53 AM
RE: Vairable Question - by wolfgang1983 - 04-15-2015, 09:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB