min_width and min_height for the upload class?

#11
[eluser]teampoop[/eluser]
There are configuration parameters for the file upload library. Check out CI/user_guide/libraries/file_uploading.html for more details.

Code:
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size']    = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';

$this->load->library('upload', $config);

// Alternately you can set preferences by calling the initialize function. Useful if you auto-load the class:
$this->upload->initialize($config);

#12
[eluser]chefnelone[/eluser]
[quote author="teampoop" date="1291246123"]There are configuration parameters for the file upload library. Check out CI/user_guide/libraries/file_uploading.html for more details.

Code:
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size']    = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';

$this->load->library('upload', $config);

// Alternately you can set preferences by calling the initialize function. Useful if you auto-load the class:
$this->upload->initialize($config);
[/quote]

I checked the user guide. But min_width and min_height are not include as parameter in the upload class. This http://ellislab.com/forums/viewthread/143418/#730179 shows a way to include these parameters... but it isn't working for me.

#13
[eluser]teampoop[/eluser]
oh MIN... not MAX.. sorry I didn't read that right either.. Tongue

#14
[eluser]Dennis Rasmussen[/eluser]
12 replies and none of them of any value Tongue
Lol InsiteFX haha (btw it's min- and max- in css and doesn't work in IE true).

Anyway for chefnelone:
What error are you getting when using the instructions in that post?
Did you remember to add an error message as well?

#15
[eluser]chefnelone[/eluser]
[quote author="Dennis Rasmussen" date="1291301868"]12 replies and none of them of any value Tongue
Lol InsiteFX haha (btw it's min- and max- in css and doesn't work in IE true).

Anyway for chefnelone:
What error are you getting when using the instructions in that post?
Did you remember to add an error message as well?[/quote]

hi dennis.
I get no error messages. It is just ignored.
I'm using it to add a restriction when uploading image files.
I need to the images to be bigger than: 800x600. But the restriction doesn't work since it uploads images smaller than those values.(without error messages)

I carefully followed all the instructions but I can't get it working.

#16
[eluser]Dennis Rasmussen[/eluser]
Show us your final code (library and controller)

#17
[eluser]chefnelone[/eluser]
I attached: application/libraries/Upload.php
I wrapped my changes with '//ADDED' (useful to make a search to spot modifications from original class)


And here part of the method that fire the Upload class:
Code:
function upload_photos(){
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '1024';
        $config['max_width']  = '1200';
        $config['max_height']  = '1200';
        $config['min_width']  = '800';
        $config['min_height']  = '600';
        
        $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload() )
        {
            $error = array('error' => $this->upload->display_errors());
            $errores ='';
            foreach($error as $value){
                $errores .= $value;
            }
/*             $this->firephp->log( $errores ); */
            echo $errores;
            
            $procesoCompleto = FALSE;
        }    
        else
        {
//do something else.

}

}

I'm using firePhp, then I can get any data in the controller, just in case it helps...

#18
[eluser]Dennis Rasmussen[/eluser]
Line 718 to 728 should start at 715 before "return FALSE".
Notice where the $D array is set at line 704, but you're using it outside the scope.

Let me know of the result Smile

#19
[eluser]chefnelone[/eluser]
[quote author="Dennis Rasmussen" date="1291310307"]Line 718 to 728 should start at 715 before "return FALSE".
Notice where the $D array is set at line 704, but you're using it outside the scope.

Let me know of the result Smile[/quote]

Thanks dennis!
You hit the point!
Works like a charm.

I noticed that the message errors are the same for max_width and for min_width.
Can I change this with some setting in the class or do I need to change the code?
Anyway this is not any problem though...

#20
[eluser]Dennis Rasmussen[/eluser]
Error message is displayed at line 250.
It's unfortunately shared between min and max.

You could do something like this:

Code:
if ($this->min_width > 0 AND $D['0'] < $this->min_width)                    
        {
            $this->invalid_dimensions_min = TRUE;
            return FALSE;
        }
                    
        if ($this->min_height > 0 AND $D['1'] < $this->min_height)                
        {
            $this->invalid_dimensions_min = TRUE;
            return FALSE;
        }
Code:
if ( ! $this->is_allowed_dimensions())
        {
            if ( $this->invalid_dimensions_min === TRUE )
            {
                $this->set_error('upload_invalid_dimensions_min');
            }
            else
            {
                $this->set_error('upload_invalid_dimensions');
            }
            return FALSE;
        }


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.