• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issue with image resizing

#1
[eluser]dorwin[/eluser]
Hey,

There is my first trouble I don't find a solution in the manual !

I'm french, so please excuse my English !

I have an upload form, and i would like resize the uploaded image but it seems to not want to work and I dont undersand why. I use wamp with the latest php and apache version, GD library is activated.

There is my controller :

Code:
<?php
class Screen extends Controller {

    function screen()
    {
        parent::Controller();
    }


/*
| -------------------------------------------------------------------
|  Fonction index : http://www.****.com/screen.html
| -------------------------------------------------------------------
*/
    function index()
    {
        //----Génération des meta + titre-----------------------
        $data['title'] = 'Massiveplayers :: Interface';
        $data['meta'] = array(
        array('name' => 'description', 'content' => 'Interface'),
        array('name' => 'keywords', 'content' => 'massiveplayer, interface'),
        array('name' => 'robots', 'content' => 'no-cache'),
        array('name' => 'Content-type', 'content' => 'text/html; charset=utf-8', 'type' => 'equiv')
        
    
    );
    }


/*
| -------------------------------------------------------------------
|  Fonction add_interface : http://www.****.com/screen/add_interface.html
| -------------------------------------------------------------------
| Description : Formulaire d'ajout d'une image (upload only, à voir pour image déjà hébergé)
*/    
    function add_interface()
    {
        //----Génération des meta + titre-----------------------
        $data['title'] = 'Massiveplayers :: Interface';
        $data['meta'] = array(
        array('name' => 'description', 'content' => 'Interface'),
        array('name' => 'keywords', 'content' => 'massiveplayer, interface'),
        array('name' => 'robots', 'content' => 'no-cache'),
        array('name' => 'Content-type', 'content' => 'text/html; charset=utf-8', 'type' => 'equiv')
        );
        
        //-----Chargement des models, helpers, etc...------------------------------
        $this->load->model('model_general', 'fonctions'); //pour creer_box()
        $this->load->model('model_login', 'log'); //pour vérif si log
        $this->load->helper('url');  //pour fonction redirect
        $this->load->library('image_lib'); //pour resize, etc..
        
        //----Test si loggé, sinon renvoie sur page de log----------------------
        if (!$this->log->is_logged()) //si pas log
        {
        $this->session->set_userdata('page_after_log', 'interface/add_interface.html'); //pour rediriger vers la bonne page apres log
        //redirect('Page de log');
        die("TU NE PASSERA PAAAAAS !"); //blague
        }
        
        //----parametre d'upload + chargement--------------------------------------------
        $config['upload_path'] = './medias/';
        $config['allowed_types'] = 'jpg';
        $config['max_size']    = '500';
        $config['max_width']  = '2048';
        $config['max_height']  = '1536';
        $this->load->library('upload', $config);
        
        //------Test du fichier, affichage formulaire etc...---------------------------
        if ( ! $this->upload->do_upload('fichier')) //nom du champs en parametre
        {
        $error = array('error' => $this->upload->display_errors()); //erreur upload HELP
        $this->load->view('screen/view_add_interface', $error);
        }
        else //VALIDATION OK
        {
        //----Ajout de l'image dans session pour l'ajouter dans bdd en step 2------
        //$this->session->set_userdata('upload', '$this->upload->data()');
        
        
        $data = array('upload_data' => $this->upload->data());
        $image = $this->upload->data();
        
        
        //----Traitement de l'image------------------------------------------- (RAJOUTER IF TROP PETIT)
        //$config2['image_library'] = 'gd2';
        $config2['source_image'] = '../medias/'.$image['file_name'];
        //$config2['source_image'] = '';
        //die ($config2['source_image']);
        //$config['create_thumb'] = FALSE;
        $config2['maintain_ratio'] = TRUE;
        $config2['width'] = 800;
        $config2['height'] = 600;
        $this->load->library('image_lib', $config2);

        if (!$this->image_lib->resize()) //BUG IS APPROXYMATELY HERE !
{
    die ($this->image_lib->display_errors());
}
else
echo "<img  /> ";


        }
        
    }
}
?&gt;
Latests lines, die and echo are there for test.
I have no error message but the image is not resized..
The latest line, echo <img /> , is fill and display the image, but this forum doesn't want to keep the line maybe for security, so I attached source file.

My view :
Code:
&lt;?php echo $error; //HELP : Affiche quand même une erreur quand form pas envoyé?&gt;

        &lt;?php //Formulaire d'upload ?&gt;
        &lt;form action="add_interface.html" method="post" ENCTYPE="multipart/form-data"&gt;
               <p>
            <label for="fichier">Fichier :  </label>
            &lt;input type="file" name="fichier" /&gt;
             </p>
            <p>
            &lt;input type="Submit" value="Valider" /&gt;
            </p>
          &lt;/form&gt;

Comment are in french, but it's actually "keyword" for my mind :p, not real french sentence...

Can you help me ?

#2
[eluser]dorwin[/eluser]
Ok, I am ashamed, but after a good night's sleep, Bug is located...

in my commented bloc "//-----Chargement des models, helpers, etc...------,

I loaded image_lib without any config parametre, but manual is not clear ! Why can we read this line without any $config, first code in the manual !

Well, I assume it's not manual fault, maybe fatigue ? :p

Thanks to John for private answer Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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