Howto to resize (thumbnail) on upload file. How to reach the more easy example, for dummies.

Howto to resize (thumbnail) on upload file. How to reach the more easy example, for dummies.

aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

Hi Allan,

I came back to question: to resize (thumbnail) on upload file. I take as reference
http://beqi.datatables.net/forums/discussion/27034/document-upload-path . On it, the user MarianH , add a code to create thumbnails, but she use Mjoin on image, and therefore it done that your code to be complex. I´ve tried adapt the example to more basic, without Mjoin ( I don't use Mjoin) but don't get.
Any help will be appreciate.

Thank you in advance!
Eduardo

PD: about resize image.
I invite you to think to support resize features on next versions of Datatables ( is only my request). Nowadays Android or iPhone devices have a minimal picture of 1,8 Mb and 2,37 Mb of size, If you work with pictures on table, both bandwidth of devices ( if you treat table with pictures) as server storage can be a big problem.

<?php

/*
 * Example PHP implementation used for the index.html example
 */

// DataTables PHP library
include( "../../../../_DataTables/php/DataTables.php" );

//  vars
$site=$_POST['site']; 
$idioma='es';  

// TRY CODE.START 

// below function, I think that  it's OK ( don't need  changes )

function make_thumb($src, $dest, $desired_width) {
    if (!file_exists($dest)) {
        $source_image = imagecreatefromjpeg($src);
        $width = imagesx($source_image);
        $height = imagesy($source_image);
        $desired_height = floor($height * ($desired_width / $width));
        $virtual_image = imagecreatetruecolor($desired_width, $desired_height);
        imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
        imagejpeg($virtual_image, $dest);
    }
}

//  below function ( need  changes ) because it was design to used Mjoin on image. 
// If  you don't use Mjoin on image, how to make more simple? (if you dont need Mjoin on image) 

function thumbnails($db, $values) {
        $files = array();
        
    // HERE (below lines) If I don't use Mjoin of image, what i've to modify on below loops? 
      
      // "image-many-count"  (unknown params for me)  , need change? ,  below:
        for ($i=0 ; $i<=$values["image-many-count"]-1 ; $i++ ) {   
           $result = $db->sql('SELECT system_path FROM files WHERE id='.$values["image"][$i]["id"].';' ); 
            while ($row = $result->fetch()) {
                $files[] = $row['system_path'];
            }
        }
        foreach ($files as &$file) {
             $path_parts = pathinfo($file);
 
          //  'dirname' and  'basename' , (unknown params for me) , need change? , below:
            make_thumb($file, $path_parts['dirname']."/thumbnails/".$path_parts['basename'], 75);
        }
}

//  TRY CODE.END


// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Join,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate;

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'chef_recomd' )
    ->fields(
        Field::inst( 'site' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'id_lang' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'nombre' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'condimentos' ),
        Field::inst( 'es_un' )->validator( 'Validate::notEmpty' ), 
        Field::inst( 'alergeno' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'precio' )->validator( 'Validate::numeric' ),
        Field::inst( 'prec_terraza' )->validator( 'Validate::numeric' ),
        Field::inst( 'nota_item' ),
        Field::inst( 'image' )
            ->setFormatter( 'Format::nullEmpty' )
            
            ->upload( 
                Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/upload/__ID__.__EXTN__' )

                ->db( 'files', 'id', array(
                    'site'          =>$site,
                    'filename'    => Upload::DB_FILE_NAME,
                    'filesize'    => Upload::DB_FILE_SIZE,
                    'web_path'    => Upload::DB_WEB_PATH,
                    'system_path' => Upload::DB_SYSTEM_PATH
                ) )
                ->validator( function ( $file ) {
                    return$file['size'] >= 3500000 ?
                        "Files must be smaller than 3500K o 3,5 Mb" :
                        null;
                } )
                ->dbClean( function ( $data ) {
                                // Remove the files from the file system
                                for ( $i=0, $ien=count($data) ; $i<$ien ; $i++ ) {
                                    unlink( $data[$i]['system_path'] );
                                }
                 
                                // Have Editor remove the rows from the database
                                return true;
                            } )

                ->allowedExtensions( array( 'png', 'jpg', 'gif' ), "Please upload an image file" )
            ),
        Field::inst( 'creado_date' )
        )


    
          ->on('postCreate', function ($editor, $id, $values, $row) use ($db){
            thumbnails($db, $values);
            //var_dump($values); // ONLY TEST
            })
            
         ->on('postEdit', function ($editor, $id, $values, $row) use ($db){
           thumbnails($db, $values);
            //var_dump($values);  // ONLY TEST
            })

        ->where( 'site', $site)
            ->where( 'id_lang', $idioma ) 
    ->process( $_POST )
    ->json();

«1

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Thanks for posting your code - I'm sure others will really appreciate it!

    I invite you to think to support resize features on next versions of Datatables

    Of images? Do you mean a pre-built function similar to your one above that will resize images to thumbnails?

    Allan

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Hi Allan,

    Yes, resize images on server-side

    NOTE: the code (above) currently NOT WORK. It have a problema (unknown for me), I ´m working to solve, but I think that the problema are when I pass the values on the function thumbnails($db, $values) on 114 and 119 lines.

    The ($values) array, have not none information of upload file. If you do var_dump($values) don't show any upload file information.

    How I can to see the upload file Information ( the array that keep the information of upload file ) . Please, can you tell me how to show the array taht have the upload file information with the command var_dump() , can you show me an example?

    Thank you Allan!

    Best Regards
    Eduardo.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    You are correct - the postCreate server-side event does not have any information about the uploaded file. It is the upload action callback that is called async to the rest of the form that has the file information.

    The documentation shows how you can provide a custom callback that will move / modify or otherwise handle the files. It is in that callback that you would create the thumbnails as you have access to the uploaded file there.

    Allan

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Thank you Allan,
    Now, I understand and I will work on base to the documentation that you appointed.

    Best regards, Eduardo.

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Hi Allan,

    I've used code example of custom actions from your documentation and I got a error (below). How I can to solve?
    Thank you, Eduardo

    error:

    fieldErrors:[{name: "image",…}]
    0:{name: "image",…}
    name:"image"
    status:"Cannot set path information in database if a custom method is used to save the file."
    

    My code:

                ->upload( 
                // standard call, disable.  
                    //Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/upload/__ID__.__EXTN__' ),
                    
                    // Custom upload actions. start
                        Upload::inst( function ( $file, $id ) {
                          move_uploaded_file( $file['tmp_name'], '/uploads/'.$id );
                          var_dump($file, $id);
                          return $id;
                      } )
                    // Custom upload actions.  end
                    
                    ->db( 'files', 'id', array(
                        'site'          =>$site,
                        'filename'    => Upload::DB_FILE_NAME,
                        'filesize'    => Upload::DB_FILE_SIZE,
                        'web_path'    => Upload::DB_WEB_PATH,
                        'system_path' => Upload::DB_SYSTEM_PATH
                    ) )
                    ->validator( function ( $file ) {
                        return$file['size'] >= 3500000 ?
                            "Files must be smaller than 3500K o 3,5 Mb" :
                            null;
                    } )
                    ->dbClean( function ( $data ) {
                                    // Remove the files from the file system
                                    for ( $i=0, $ien=count($data) ; $i<$ien ; $i++ ) {
                                        unlink( $data[$i]['system_path'] );
                                    }
                     
                                    // Have Editor remove the rows from the database
                                    return true;
                                } )
    
                    ->allowedExtensions( array( 'png', 'jpg', 'gif' ), "Please upload an image file" )
                ),
    
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Hi,

    As the error says, you can't use DB_WEB_PATH or DB_SYSTEM_PATH when you provide a custom action since it doesn't know where you are writing the file to!

    What you would need to do is do an UPDATE on the database row in question with the web path that your custom action sets.

    Allan

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Hi Allan,

    Thank you for you help. I´ve add an UPDATE and I´ve make a progress, but now have two issues, perhaps is a "collateral issues" when you use upload custom actions:

    1. The name of file that uploaded: it keep the name of file (honeymoon3.jpg) on directory hosting and also on "filename" ( field of table). When you use "standard upload file" ( when not use upload custom actions), the filename is rename with the ID of row inserted of table as name of file, and evething work ok (the image is loaded) . On my code, the image don't loaded (don't found ). I think that if I could to change the filename (both on table as hosting folder ), with the ID of row inserted of table, everything work fine, right?. How I can to do?
    2. The function dbClean() don't work, (don't remove the file), perhaps because above issue?

    Any help are welcome.

    Thank you,
    Eduardo

    Row of table ( 675 is a ID row on table):

       ID /   $site  /   filename    /   size    /     web_path    /    system_path
    
     "675" "342800010" "honeymoon3.jpg" "138552" "/upload/675.jpg"  "/home/my_domain_here/www/upload/675.jpg"
    

    My code:

    if ( $_SERVER["REQUEST_METHOD"] == "POST" ) { // comprueba que el metodo es     POST (se hizo)
    
    // Web and thumb path to file
    $webPath = '/upload/';
    $thumbPath = '/thumbnails/';
    // System path
    $sysPath = $_SERVER['DOCUMENT_ROOT'] . $webPath; //ori
    // Create an array to hold variables to be used in the closure function
     $varArray = [
      "webPath"  => $webPath,
      "sysPath"   => $sysPath,
    ];
    }
    
    ....
    
            ->upload( 
                // Custom upload actions. start
                    Upload::inst(  function ( $file, $id ) use ( $varArray, $db ) {
    
                     move_uploaded_file( $file['tmp_name'] , $varArray["sysPath"] . $file['name'] );                
                     $db->update(
                        'files', // Database table to update
                        [
                         "web_path" => $varArray["webPath"] .$id. '.jpg', //work
                         "system_path" => $varArray["sysPath"]  .$id. '.jpg',  //work
                        ],
                        [ "id" => $id ]
                      );
                      return $id;
                        //var_dump($file); //ONLY TEST
                    } ) 
                    // Custom upload actions. end   
    
                ->db( 'files', 'id', array(
                    'site'          =>$site,
                    'filename'    => Upload::DB_FILE_NAME,
                    'filesize'    => Upload::DB_FILE_SIZE,
                    //'web_path'    => Upload::DB_WEB_PATH, //ori
                    //'system_path' => Upload::DB_SYSTEM_PATH //ori
    
                ) )
                ->validator( function ( $file ) {
                    return$file['size'] >= 3500000 ?
                        "Files must be smaller than 3500K o 3,5 Mb" :
                        null;
                } )
                ->dbClean( function ( $data ) {  // It`s  Works when use "upload custom actions" ??
                                // Remove the files from the file system
                                for ( $i=0, $ien=count($data) ; $i<$ien ; $i++ ) {
                                    unlink( $data[$i]['system_path'] );
                                }
    
                                // Have Editor remove the rows from the database
                                return true;
                            } )
    
                ->allowedExtensions( array( 'png', 'jpg', 'gif' ), "Please upload an image file" )
            ),
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    If you ssh into the server and type ls -l in the upload directory - what does it show?

    Thanks,
    Allan

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1
    edited March 2017

    Hi Allan,
    Thank you for you help,

    Here the output of command, you can see that when use "standard uploaded file" the name of file uploaded changes to ID of table row inserted (files until 10 mars). When you use "upload custom action" - my code - the name of file uploaded no change (files from 16 mars) but it changes on "web_path" , "system_path" fields of the table (see below). I think this is the razon which the image is not found, right?

    Let me know,
    Eduardo

    my_domain@ssh1.20gp.ha.ovh.net ~/www/upload $ ls -l
    -rw-r--r--+ 1 tripntry users   51303 26 oct.  13:38 546.jpg
    -rw----r--+ 1 tripntry users   56618 26 oct.  15:08 558.jpg
    -rw----r--+ 1 tripntry users   53684 22 nov.  09:34 568.png
    -rw----r--+ 1 tripntry users   51303 10 janv. 19:38 570.jpg
    -rw----r--+ 1 tripntry users   52026 10 janv. 19:39 571.jpg
    -rw----r--+ 1 tripntry users   52267 10 janv. 19:39 572.jpg
    -rw----r--+ 1 tripntry users   51696 10 janv. 19:39 573.jpg
    -rw----r--+ 1 tripntry users 1812199  6 mars  20:11 605.jpg
    -rw----r--+ 1 tripntry users   56650  9 mars  20:38 633.jpg
    -rw----r--+ 1 tripntry users   56650  9 mars  20:43 634.jpg
    -rw----r--+ 1 tripntry users   56650 10 mars  21:30 660.jpg
    
    -rw----r--+ 1 tripntry users   38860 16 mars  19:11 honeymoon2.jpg
    -rw----r--+ 1 tripntry users  138552 16 mars  19:31 honeymoon3.jpg
    -rw----r--+ 1 tripntry users  107975 16 mars  18:16 Jacuzzi.jpg
    -rw----r--+ 1 tripntry users   56650 17 mars  18:06 jacuzzi_nieve.jpg
    -rw----r--+ 1 tripntry users  139606 16 mars  19:25 Relajacion-bodas.jpg
    

    And the table is

    675,"342800010","honeymoon3.jpg","138552","/upload/675.jpg","/home/tripntry/www/upload/675.jpg",NULL,NULL
    605,"342800010","20161030_215613.jpg","1812199","/upload/605.jpg","/home/tripntry/www/upload/605.jpg",NULL,NULL
    573,"342800010","dried-1536417_640-2.jpg","51696","/upload/573.jpg","/home/tripntry/www/upload/573.jpg",NULL,NULL
    571,"342800010","cakes-314378_640.jpg","52026","/upload/571.jpg","/home/tripntry/www/upload/571.jpg",NULL,NULL
    570,"342800010","546.jpg","51303","/upload/570.jpg","/home/tripntry/www/upload/570.jpg",NULL,NULL
    572,"342800010","cod-1252654_640-2.jpg","52267","/upload/572.jpg","/home/tripntry/www/upload/572.jpg",NULL,NULL
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Correct! You need to change the second argument being passed to move_uploaded_file(). Currently you are telling it to store the file with its name! You need to change it to be id plus extension.

    Allan

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Hi Allan,

    Thank you for you help.

    We are give a step more!. Now the name of file is rename on server hosting with ID of row inserted (below PHP code) but is not renamed on DB table. The field "filename" keep your original name...this can be a problem?, because the images (pictures ) don't show neither a form (when pickup a file) nor on table, on both (form and table) appear a rectangle empty. With Dev tools (on table) appear "undefined" (see below):

    Thank you in advance,
    Eduardo

    <img src="undefined" class="" width="200" height="133">
    

    if manualy (from dev tools) i write /upload/571.jpg , the picture is showed on table:

    <img src="/upload/571.jpg" class="" width="200" height="133">
    

    JSON output : ( note: "web_path" field don't came. this is a problem? )

    {id: "571", site: "342800010", filename: "cakes-314378_640.jpg", filesize: "52026"}
    

    And related issue:
    When you select a row and give Delete button , appear a error : https://datatables.net/manual/tech-notes/12., but if you give again Delete , the row is remove and close de dialog and the file is not remove form server. Any idea?

    Current PHP code, related to upload()

    // este code esta relacionado con "upload custom actions". INICIO
    if ( $_SERVER["REQUEST_METHOD"] == "POST" ) { // comprueba que el metodo es POST (se hizo)
    
    // paths
      $webPath = '/upload/';
      $thumbPath = '/thumbnails/';
      $sysPath = $_SERVER['DOCUMENT_ROOT'] . $webPath; //ori
      
    // Create an array to hold variables to be used in the closure function
      $varArray = [
        "webPath"  => $webPath,
        "sysPath" => $sysPath,
    ];
    }
                ->upload( 
                    // Custom upload actions. start
                        Upload::inst(  function ( $file, $id ) use ( $varArray, $db ) {
                          move_uploaded_file( $file['tmp_name'] , $varArray["sysPath"] .$id. '.jpg' );
                          $db->update(
                            'files', // Database table to update
                            [
                             "web_path" => $varArray["webPath"] .$id. '.jpg', //work
                             "system_path" => $varArray["sysPath"]  .$id. '.jpg',  //work
                            ],
                            [ "id" => $id ]
                          );
                          return $id;
                        } ) 
                        // Custom upload actions. end       
                    ->db( 'files', 'id', array(
                        'site'          =>$site,
                        'filename'    => Upload::DB_FILE_NAME,
                        'filesize'    => Upload::DB_FILE_SIZE,
                        //'web_path'    => Upload::DB_WEB_PATH, //ori
                        //'system_path' => Upload::DB_SYSTEM_PATH //ori
                    ) )
                    ->validator( function ( $file ) {
                        return$file['size'] >= 3500000 ?
                            "Files must be smaller than 3500K o 3,5 Mb" :
                            null;
                    } )
                    ->dbClean( function ( $data ) {
                                    // Remove the files from the file system
                                    for ( $i=0, $ien=count($data) ; $i<$ien ; $i++ ) {
                                        unlink( $data[$i]['system_path'] ); // Dont work. I´m using "upload custom actions" 
                                    }
                     
                                    // Have Editor remove the rows from the database
                                    return true;
                                } )
    
                    ->allowedExtensions( array(  'jpg'  ), "Please upload an image file with extension jpg" )
    
                );
    
    

    Current JS code, related to image (form and table):

            fields: [ 
    
                {
                    label: "Imagen:",
                    name: "image",
                    //status: "This field is required", //add, foto lo usa scan and get  app
                    type: "upload",
                    display: function ( file_id ) {
                        return '<img src="'+table.file( 'files', file_id ).web_path+'"/>'; //ori
                    },
                    clearText: "Clear",
                    ajaxData: function ( d ) {d.append( 'site', id_establecimiento() ); }, // here I´ve add  " }, "
                    noImageText: 'No image'
                },
    
    
            columns: 
                [
            
    
                    {
                        data: "image",
                        render: function ( file_id ) {
                            return file_id ?
                            '<img src="'+table.file( 'files', file_id ).web_path+'" class="" width="200" height="133"/>' :
                                null;
                        },
                        defaultContent: "No image",
                        title: "Imagen"
                    },
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Change:

    //'web_path' => Upload::DB_WEB_PATH, //ori
    //'system_path' => Upload::DB_SYSTEM_PATH //ori

    To be:

                        'web_path'    => '',
                        'system_path' => ''
    

    The problem was that web_path and system_path were not being read since they weren't in the list of options. That will jsut set them to be an empty string.

    Allan

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Hi Allan, you are great!

    Now the image on the form and also on table is showed (solved!)
    Also, the rezise function now works!, This fuction make_thumb() create a thubnails on folder on server. Also I add two new fields on DB table ("webPathTumbs1" and "sysPathThumbs1) , this action allow to recover the thumbnails files (lower size) when the table (columns) is created, so the performance is better ( on 3G mobile enviroment).

    Only a final question to reach the goal:
    - When click on Delete button on table, how to remove both files? (file uploaded and thunbnail created) . I´ve try but give me an error ( please see my wrong code, below, line 78).
    Any idea?

    Thank you in advance!
    Eduardo

    if ( $_SERVER["REQUEST_METHOD"] == "POST" ) { // comprueba que el metodo es POST (se hizo)
    
    // Web and thumbs paths to file
      $webPath = '/upload/';
      $webPathTumbs1 = '/upload/thumbnails/';
    // System paths
        $sysPath = $_SERVER['DOCUMENT_ROOT'] . $webPath; 
        $sysPathThumbs1 = $_SERVER['DOCUMENT_ROOT'] . $webPathTumbs1; 
    // Create an array to hold variables to be used in the closure function
      $varArray = [
        "webPath"  => $webPath,
        "sysPath" => $sysPath,
        "webPathTumbs1" =>  $webPathTumbs1,
        "sysPathThumbs1" => $sysPathThumbs1,
    ];
    }
    
    function make_thumb($src, $dest, $desired_width) {
        if (!file_exists($dest)) {
            $source_image = imagecreatefromjpeg($src);
            $width = imagesx($source_image);
            $height = imagesy($source_image);
            $desired_height = floor($height * ($desired_width / $width));
            $virtual_image = imagecreatetruecolor($desired_width, $desired_height);
            imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
            imagejpeg($virtual_image, $dest);
        }
    }
    
    ....
    
    // Build our Editor instance and process the data coming from _POST
    Editor::inst( $db, 'chef_recomd' )
        ->fields(
    
            Field::inst( 'image' )
                ->setFormatter( 'Format::nullEmpty' )
                
                ->upload( 
                    // Custom upload actions. start
                        Upload::inst(  function ( $file, $id ) use ( $varArray, $db ) {
                         
                          move_uploaded_file( $file['tmp_name'] , $varArray["sysPath"] .$id. '.jpg' );
                             make_thumb($varArray["sysPath"] .$id. '.jpg', $varArray["sysPathThumbs1"].$id. '.jpg', 480);
                          $db->update(
                            'files', // Database table to update
                            [
                             "web_path" => $varArray["webPath"] .$id. '.jpg', //work
                             "system_path" => $varArray["sysPath"]  .$id. '.jpg',  //work
                             "web_path_thumb1" => $varArray["webPathTumbs1"] .$id. '.jpg', //work
                             "system_path_thumb1" => $varArray["sysPathThumbs1"]  .$id. '.jpg',  //work
                            ],
                            [ "id" => $id ]
                          );
               
                          return $id;
                        } ) 
                        // Custom upload actions. end       
                    ->db( 'files', 'id', array(
                        'site'          =>$site,
                        'filename'    => Upload::DB_FILE_NAME,
                        'filesize'    => Upload::DB_FILE_SIZE,
                        'web_path'    => '', //work!
                        'system_path' => '', //work!
                        'web_path_thumb1'    => '', //work!
                        'system_path_thumb1' => '', //work!
    
                    ) )
                    ->validator( function ( $file ) {
                        return$file['size'] >= 3500000 ?
                            "Files must be smaller than 3500K o 3,5 Mb" :
                            null;
                    } )
                    ->dbClean( function ( $data ) {
                                    // Remove the files from the file system
                                    for ( $i=0, $ien=count($data) ; $i<$ien ; $i++ ) {
                                        unlink( $data[$i]['system_path'] ); // work, remove only upload file, not thumb file created
                                        //unlink( $data[$i]['system_path_thumb1'] );  // don´t work, give me error
                                    }
                     
                                    // Have Editor remove the rows from the database
                                    return true;
                                } )
    
                    ->allowedExtensions( array(  'jpg'  ), "Please upload an image file with jpg extension" )
    
                ),
            Field::inst( 'creado_date' )
            )
    
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    What's the error that the unlink function gives?

    Allan

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Hi Allan,

    Thank you for you help.

    Unlink function give none errors and it works, but only remove the file on 'system_path' (path indicated on unlink function).

    I want to remove the file on two locations (or all locations if I create more than one thumbnails) . When I click on Delete button I want to remove the files on : 'system_path' , 'system_path_thumb', 'system_path_thumb_1', ...

    How to remove at once all files if are on more than one location?

    My best greetings,
    Eduardo

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    So the second unlink doesn't result in any errors? Do you have all PHP warnings turned on?

    Allan

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Hi Allan,

    My apologies, unlink function works and delete files, has been my error on my tests. Current code that works:

                unlink( $data[$i]['system_path'] ); // upload file  folder
                unlink( $data[$i]['system_path_thumb1'] );  //my thumbnails  file folder #1
    

    I´m goint to try with 3 folders (/upload, /upload_thumb1, /upload_thumb2) and if everything works, i will post the final code.

    Thank you so much!!
    Eduardo

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Excellent - good to hear that its all looking good now.

    Allan

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Hi Allan,

    Your help was decisive for to reach the goal, so thank very much.
    I post de FINAL CODE (below) that works on my example. It is not a elegant code (sure it can doing better) but it works.

    My best regards,
    Eduardo

    <?php
    
    /*
     * Example PHP implementation used for the index.html example
     */
    
    // DataTables PHP library
    include( "../../../../_DataTables/php/DataTables.php" );
    
    $site=$_POST['site']; 
    
    // related to "upload custom actions". 
    if ( $_SERVER["REQUEST_METHOD"] == "POST" ) { // comprueba que el metodo es POST (se hizo)
    
    // Web and thumbs paths to file
      $webPath = '/upload/';
      $webPathThumbs1 = '/upload/thumbnails/';
      $webPathThumbs2 = '/upload/thumbnails2/';
      
    // System paths
        $sysPath = $_SERVER['DOCUMENT_ROOT'] . $webPath; 
        $sysPathThumbs1 = $_SERVER['DOCUMENT_ROOT'] . $webPathThumbs1; 
        $sysPathThumbs2 = $_SERVER['DOCUMENT_ROOT'] . $webPathThumbs2; 
        
    // Create an array to be used in function
      $varArray = [
        "webPath"  => $webPath,
        "sysPath" => $sysPath,
        "webPathTumbs1" =>  $webPathThumbs1,
        "sysPathThumbs1" => $sysPathThumbs1,
        "webPathThumbs2" => $webPathThumbs2,
        "sysPathThumbs2" => $sysPathThumbs2
    ];
    }
    
    // resize function. Use  GD libraries ( native from PHP 5 )
    function make_thumb($src, $dest, $desired_width) {
        if (!file_exists($dest)) {
            $source_image = imagecreatefromjpeg($src);
            $width = imagesx($source_image);
            $height = imagesy($source_image);
            $desired_height = floor($height * ($desired_width / $width));
            $virtual_image = imagecreatetruecolor($desired_width, $desired_height);
            imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
            imagejpeg($virtual_image, $dest);
        }
    }
    
    
    // Alias Editor classes so they are easy to use
    use
        DataTables\Editor,
        DataTables\Editor\Field,
        DataTables\Editor\Format,
        DataTables\Editor\Mjoin,
        DataTables\Editor\Join,
        DataTables\Editor\Upload,
        DataTables\Editor\Validate;
    
    // Build our Editor instance and process the data coming from _POST
    Editor::inst( $db, 'chef_recomd' )
        ->fields(
            Field::inst( 'site' )->validator( 'Validate::notEmpty' ),
            Field::inst( 'id_lang' )->validator( 'Validate::notEmpty' ),
            Field::inst( 'nombre' )->validator( 'Validate::notEmpty' ),
            Field::inst( 'condimentos' ),
            Field::inst( 'image' )
                ->setFormatter( 'Format::nullEmpty' )
                
                ->upload( 
                    // Custom upload actions. start
                        Upload::inst(  function ( $file, $id ) use ( $varArray, $db ) {
                          
                          move_uploaded_file( $file['tmp_name'] , $varArray["sysPath"] .$id. '.jpg' );
                            make_thumb($varArray["sysPath"] .$id. '.jpg', $varArray["sysPathThumbs1"].$id. '.jpg', 480);
                            make_thumb($varArray["sysPath"] .$id. '.jpg', $varArray["sysPathThumbs2"].$id. '.jpg', 120); 
                          
                          $db->update(
                            'files', // Database table to update
                            [
                             "web_path" => $varArray["webPath"] .$id. '.jpg', 
                             "system_path" => $varArray["sysPath"]  .$id. '.jpg',  
                             "web_path_thumb1" => $varArray["webPathTumbs1"] .$id. '.jpg', 
                             "system_path_thumb1" => $varArray["sysPathThumbs1"]  .$id. '.jpg',  
                             "web_path_thumb2" => $varArray["webPathThumbs2"] .$id. '.jpg', 
                             "system_path_thumb2" => $varArray["sysPathThumbs2"]  .$id. '.jpg',  
                            ],
                            [ "id" => $id ]
                          );
                          return $id;
                        } ) 
                        // Custom upload actions. end       
                    
                    ->db( 'files', 'id', array(
                        'site'          =>$site,
                        'filename'    => Upload::DB_FILE_NAME,
                        'filesize'    => Upload::DB_FILE_SIZE,
                        'web_path'    => '', 
                        'system_path' => '', 
                        'web_path_thumb1'    => '', 
                        'system_path_thumb1' => '', 
                        'web_path_thumb2'    => '', 
                        'system_path_thumb2' => '', 
    
                    ) )
                    ->validator( function ( $file ) {
                        return$file['size'] >= 3000000 ?
                            "Files must be smaller than 3000K o 3,0 Mb" :
                            null;
                    } )
                    ->dbClean( function ( $data ) {
                                    // Remove the files from the file system
                                    for ( $i=0, $ien=count($data) ; $i<$ien ; $i++ ) {
                                        unlink( $data[$i]['system_path'] ); // upload file  folder
                                        unlink( $data[$i]['system_path_thumb1'] );  //my thumbnails  file folder #1
                                        unlink( $data[$i]['system_path_thumb2'] );  //my thumbnails  file folder #2
                                    }
                                    // Have Editor remove the rows from the database
                                    return true;
                                } )
    
                    ->allowedExtensions( array(  'jpg'  ), "Please upload an image file, ONLY .jpg " )
    
                ),
            Field::inst( 'creado_date' )
            )
    
            ->where( 'site', $site)
        ->process( $_POST )
        ->json();
    
    
  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Hi Allan,

    One more step beyond, can i use "where conditions" on upload file?.

    I mean: upload file JSON give me all files that I´ve uploaded , when I use "upload custom action" ( above thread), but I need only files (rows) that match with the $site variable. P.e:

    How to get files (rows) that ONLY belong to site: "342800010" ?

    Where condition ( above thread) work fine with [data] , but not with [files_chef_recomd] (see below JSON outputs)

    ->where( 'site', $site)
    

    Thank you in advance
    Eduardo

    JSON output from [files_chef_recomd]

    files_chef_recomd
    :
    {792: {id: "792", site: "342800010", filename: "cakes-314378_640.jpg", filesize: "68309",…},…}
    792
    :
    {id: "792", site: "342800010", filename: "cakes-314378_640.jpg", filesize: "68309",…}
    793
    :
    {id: "793", site: "342800010", filename: "cod-1252654_640.jpg", filesize: "80948",…}
    794
    :
    {id: "794", site: "342800010", filename: "grilled-1631727_640.jpg", filesize: "70264",…}
    795
    :
    {id: "795", site: "34280012", filename: "cod-1252654_640.jpg", filesize: "80948",…}
    

    JSON output from [data]

    data
    :
    0
    :
    {DT_RowId: "row_327", site: "342800010", id_lang: "es", nombre: "Merluza en salsa de frutos rojos",…}
    1
    :
    {DT_RowId: "row_328", site: "342800010", id_lang: "es",…}
    2
    :
    {DT_RowId: "row_330", site: "342800010", id_lang: "es", nombre: "Helado de frambuesa",…}
    
  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Hi Allan,

    Right now, I´ve seen that 1.6.2 release include "where" sentence on upload file, congrats!!

    Please, can you tell me a example of use?
    If there are to add another "where" , please can you said me what line should to go ? You can to use above code as reference to point the line, it will be helpful for me.

    Thank you !
    Eduardo

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    In between line 105 and 106. It is a method of the Upload class so it could go anywhere on the Upload chain, but that's as good as anywhere.

    Allan

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Hi Allan;

    As your comment, a first test of "where" sentence on upload file with custom action with v1.6.2 don't work on my code, perhaps I don't do it well. Can you review my syntax? (line 44)

    $site=$_POST['site']; 
    ...
    
                ->upload( 
                    // Custom upload actions. start
                        Upload::inst(  function ( $file, $id ) use ( $varArray, $db ) {
               
                         move_uploaded_file( $file['tmp_name'] , $varArray["sysPath"] .$id. '.jpg' );
                         make_thumb($varArray["sysPath"] .$id. '.jpg', $varArray["sysPathThumbs1"].$id. '.jpg', 480);
                         make_thumb($varArray["sysPath"] .$id. '.jpg', $varArray["sysPathThumbs2"].$id. '.jpg', 120); 
                          $db->update(
                            'files_chef_recomd', // Database table to update
                            array ( //[
                             "web_path" => $varArray["webPath"] .$id. '.jpg',
                             "system_path" => $varArray["sysPath"]  .$id. '.jpg',  
                             //"system_path" => $varArray["sysPath"]  . $file['name']  //escribe nombre de fich.
                             "web_path_thumb1" => $varArray["webPathTumbs1"] .$id. '.jpg', 
                             "sys_path_thumb1" => $varArray["sysPathThumbs1"]  .$id. '.jpg',  
                             "web_path_thumb2" => $varArray["webPathThumbs2"] .$id. '.jpg', 
                             "sys_path_thumb2" => $varArray["sysPathThumbs2"]  .$id. '.jpg',  
                            ), //],
                            array ( "id" => $id )
                            //[ "id" => $id ]  //ori
    
                          );
               
                          return $id;
                         //var_dump($file); //ONLY TEST
                        } ) 
                        // Custom upload actions. end       
                    
                    ->db( 'files_chef_recomd', 'id', array(
                        'site'          =>$site,
                        'filename'    => Upload::DB_FILE_NAME,
                        'filesize'    => Upload::DB_FILE_SIZE,
                        'web_path'    => '', 
                        'system_path' => '', 
                        'web_path_thumb1'    => '', 
                        'sys_path_thumb1'    => '', 
                        'web_path_thumb2'    => '', 
                        'sys_path_thumb2'    => '', 
    
                    ) )
                    ->where( 'site', $site) // for upload file
    
                    ->validator( function ( $file ) {
                        return$file['size'] >= 3000000 ?
                            "Files must be smaller than 3000K o 3,0 Mb" :
                            null;
                    } )
                    ->dbClean( function ( $data ) {
    ...
    

    JSON output (files_chef_recomd): should to show only site = 342800010, but not.

    files_chef_recomd
    :
    {792: {id: "792", site: "342800010", filename: "cakes-314378_640.jpg", filesize: "68309",…},…}
    792
    :
    {id: "792", site: "342800010", filename: "cakes-314378_640.jpg", filesize: "68309",…}
    793
    :
    {id: "793", site: "342800010", filename: "cod-1252654_640.jpg", filesize: "80948",…}
    794
    :
    {id: "794", site: "342800010", filename: "grilled-1631727_640.jpg", filesize: "70264",…}
    804
    :
    {id: "804", site: "34280012", filename: "Upload.jpg", filesize: "8204",…}
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    The where() method for Upload needs to be given as a function:

    ->where( function ( $q ) use ( $site ) {
      $q->where( 'site', $site );
    } )
    

    That assumes that you are posting the site parameter to the server with the upload action.

    Allan

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Hi Allan,
    I´sorry this is new for me, so let me go to step-by-step.
    1. I´ve try your sintax, but don't get result.
    2. I´ve try with a fixed value, on line ( //ONLY for Test) , but don't get result. Should to work?
    3. I think that when step 2 work, i will review posting "site" parameter

    Thank you!
    Greetings

                    ->where( function ( $q ) use ( $site ) {
                        //$q->where( 'site', $site );
                        $q->where( 'site', "342800010" ); // ONLY for Test
                      } )
    
    

    JSON output (files_chef_recomd) whith above $q->where( 'site', "342800010" )

    files_chef_recomd
    :
    {792: {id: "792", site: "342800010", filename: "cakes-314378_640.jpg", filesize: "68309",…},…}
    792
    :
    {id: "792", site: "342800010", filename: "cakes-314378_640.jpg", filesize: "68309",…}
    793
    :
    {id: "793", site: "342800010", filename: "cod-1252654_640.jpg", filesize: "80948",…}
    794
    :
    {id: "794", site: "342800010", filename: "grilled-1631727_640.jpg", filesize: "70264",…}
    804
    :
    {id: "804", site: "34280012", filename: "Upload.jpg", filesize: "8204",…}
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Did you update the PHP libraries to 1.6.2 as well? That looks like it should work!

    Could you add ->debug( true ) immediately before the ->process( ... ) method call and then show me the JSON that the server is responding with when the table is initially loaded? It will contain the SQL statements that the libraries are using.

    Allan

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Hi Allan,
    Thank for you help.

    I´ve follow your comments , but " ->debug( true )" , adds nothing new , i mean, is the same that see with Google dev tools (sorry , perhaps is my fault ).

    So, I´ve used https://debug.datatables.net/ and I show you:

    1. libraries that currently I used (Software)

    2. JSON output that give me your Javascript snippet ( i will hope that it will be that you need).

    Greetings!

    PD: I´ve to run Javascript snippet keep above where line:

        ->where( function ( $q ) use ( $site ) {
            $q->where( 'site', "342800010" ); // ONLY for Test
        } )
    
    

    1.Software:

    DataTables  1.10.15 Up-to-date
    AutoFill    Not installed   
    Buttons 1.3.1   Up-to-date
    ColReorder  Not installed   
    Editor  1.6.2   Up-to-date
    FixedColumns    Not installed   
    FixedHeader Not installed   
    KeyTable    Not installed   
    Responsive  2.1.1   Up-to-date
    RowReorder  Not installed   
    Scroller    Not installed   
    Select  1.2.2   Up-to-date
    
    

    2.JSON output

    {
        "data": [{
            "DT_RowId": "row_327",
            "site": "342800010",
            "id_lang": "es",
            "nombre": "Merluza en salsa de frutos rojos",
            "condimentos": "Merluza (pescado), frutos rojos, salpicon de vinagre",
            "es_un": "Pescado",
            "alergeno": "Si",
            "precio": "16.30",
            "prec_terraza": "17.00",
            "nota_item": "",
            "image": "793",
            "creado_date": "2017-04-01",
            "alergenos": [{
                "id": "1",
                "name": "Gluten",
                "code": "a01"
            }, {
                "id": "5",
                "name": "Huevos",
                "code": "a03"
            }, {
                "id": "7",
                "name": "Pescado",
                "code": "a04"
            }, {
                "id": "15",
                "name": "Frutos de cascara",
                "code": "a08"
            }]
        }, {
            "DT_RowId": "row_328",
            "site": "342800010",
            "id_lang": "es",
            "nombre": "Solomillo de cerdo a la parrilla con verduras",
            "condimentos": "Solomillo (cerdo) , apio, verduras",
            "es_un": "Carne",
            "alergeno": "Si",
            "precio": "15.30",
            "prec_terraza": "16.00",
            "nota_item": "",
            "image": "794",
            "creado_date": "2017-04-01",
            "alergenos": [{
                "id": "1",
                "name": "Gluten",
                "code": "a01"
            }, {
                "id": "27",
                "name": "Apio",
                "code": "a14"
            }]
        }, {
            "DT_RowId": "row_330",
            "site": "342800010",
            "id_lang": "es",
            "nombre": "Helado de frambuesa",
            "condimentos": "frambuesa",
            "es_un": "Postres",
            "alergeno": "Si",
            "precio": "4.55",
            "prec_terraza": "5.25",
            "nota_item": "",
            "image": "792",
            "creado_date": "2017-04-01",
            "alergenos": [{
                "id": "1",
                "name": "Gluten",
                "code": "a01"
            }, {
                "id": "7",
                "name": "Pescado",
                "code": "a04"
            }, {
                "id": "17",
                "name": "Mostaza",
                "code": "a09"
            }, {
                "id": "25",
                "name": "Moluscos",
                "code": "a13"
            }]
        }],
        "options": {
            "alergenos[].id": [{
                "value": "23",
                "label": "Altramuces"
            }, {
                "value": "27",
                "label": "Apio"
            }, {
                "value": "9",
                "label": "Cacahuetes"
            }, {
                "value": "3",
                "label": "Crustaceos"
            }, {
                "value": "15",
                "label": "Frutos de cascara"
            }, {
                "value": "1",
                "label": "Gluten"
            }, {
                "value": "5",
                "label": "Huevos"
            }, {
                "value": "13",
                "label": "Leche - lactosa"
            }, {
                "value": "25",
                "label": "Moluscos"
            }, {
                "value": "17",
                "label": "Mostaza"
            }, {
                "value": "7",
                "label": "Pescado"
            }, {
                "value": "19",
                "label": "Sesamo"
            }, {
                "value": "11",
                "label": "Soja"
            }, {
                "value": "21",
                "label": "Sulfitos - SO2"
            }]
        },
        "files": {
            "files_chef_recomd": {
                "794": {
                    "id": "794",
                    "site": "342800010",
                    "filename": "grilled-1631727_640.jpg",
                    "filesize": "70264",
                    "web_path": "\/upload_chef\/794.jpg",
                    "system_path": "\/home\/tripntry\/www\/upload_chef\/794.jpg",
                    "web_path_thumb1": "\/upload_chef\/thumb1\/342800010\/794.jpg",
                    "sys_path_thumb1": "\/home\/tripntry\/www\/upload_chef\/thumb1\/342800010\/794.jpg",
                    "web_path_thumb2": "\/upload_chef\/thumb2\/342800010\/794.jpg",
                    "sys_path_thumb2": "\/home\/tripntry\/www\/upload_chef\/thumb2\/342800010\/794.jpg"
                },
                "792": {
                    "id": "792",
                    "site": "342800010",
                    "filename": "cakes-314378_640.jpg",
                    "filesize": "68309",
                    "web_path": "\/upload_chef\/792.jpg",
                    "system_path": "\/home\/tripntry\/www\/upload_chef\/792.jpg",
                    "web_path_thumb1": "\/upload_chef\/thumb1\/342800010\/792.jpg",
                    "sys_path_thumb1": "\/home\/tripntry\/www\/upload_chef\/thumb1\/342800010\/792.jpg",
                    "web_path_thumb2": "\/upload_chef\/thumb2\/342800010\/792.jpg",
                    "sys_path_thumb2": "\/home\/tripntry\/www\/upload_chef\/thumb2\/342800010\/792.jpg"
                },
                "793": {
                    "id": "793",
                    "site": "342800010",
                    "filename": "cod-1252654_640.jpg",
                    "filesize": "80948",
                    "web_path": "\/upload_chef\/793.jpg",
                    "system_path": "\/home\/tripntry\/www\/upload_chef\/793.jpg",
                    "web_path_thumb1": "\/upload_chef\/thumb1\/342800010\/793.jpg",
                    "sys_path_thumb1": "\/home\/tripntry\/www\/upload_chef\/thumb1\/342800010\/793.jpg",
                    "web_path_thumb2": "\/upload_chef\/thumb2\/342800010\/793.jpg",
                    "sys_path_thumb2": "\/home\/tripntry\/www\/upload_chef\/thumb2\/342800010\/793.jpg"
                },
                "804": {
                    "id": "804",
                    "site": "34280012",
                    "filename": "Upload.jpg",
                    "filesize": "8204",
                    "web_path": "\/upload_chef\/804.jpg",
                    "system_path": "\/opt\/bitnami\/apps\/joomla\/htdocs\/upload_chef\/804.jpg",
                    "web_path_thumb1": "\/upload_chef\/thumb1\/342800010\/804.jpg",
                    "sys_path_thumb1": "\/opt\/bitnami\/apps\/joomla\/htdocs\/upload_chef\/thumb1\/342800010\/804.jpg",
                    "web_path_thumb2": "\/upload_chef\/thumb2\/342800010\/804.jpg",
                    "sys_path_thumb2": "\/opt\/bitnami\/apps\/joomla\/htdocs\/upload_chef\/thumb2\/342800010\/804.jpg"
                }
            }
        }
    }
    
  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    So, I´ve used https://debug.datatables.net/

    What is the debug code which the debugger gave you?

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Could you also show us the PHP you are using please? Make sure you add it before you call process().

    Allan

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Hi Allan,
    Thank you for you help

    My apologies, I had a mistake on my call to php file. I'm sorry, debug( ) now works! , output below.

    Additional info: I´m used https protocol on *.html files, if that helps.

    About PHP version: 5.6.19 , on Headers (Chrome DevTools ) :

    Cache-Control:max-age=0, no-cache
    Connection:Keep-Alive
    Content-Encoding:gzip
    Content-Length:919
    Content-Type:text/html; charset=UTF-8
    Date:Thu, 27 Apr 2017 11:31:39 GMT
    Keep-Alive:timeout=2, max=98
    Server:Apache
    Vary:Cookie,Accept-Encoding
    X-Frame-Options:SAMEORIGIN
    X-Mod-Pagespeed:1.9.32.13-0
    X-Powered-By:PHP/5.6.19
    

    JSON output , with ->debug( true ):

    {"data":[{"DT_RowId":"row_327","site":"342800010","id_lang":"es","nombre":"Merluza en salsa de frutos rojos","condimentos":"Merluza (pescado), frutos rojos, salpicon de vinagre","es_un":"Pescado","alergeno":"Si","precio":"16.30","prec_terraza":"17.00","nota_item":"","image":"793","creado_date":"2017-04-01","alergenos":[{"id":"1","name":"Gluten","code":"a01"},{"id":"5","name":"Huevos","code":"a03"},{"id":"7","name":"Pescado","code":"a04"},{"id":"15","name":"Frutos de cascara","code":"a08"}]},{"DT_RowId":"row_328","site":"342800010","id_lang":"es","nombre":"Solomillo de cerdo a la parrilla con verduras","condimentos":"Solomillo (cerdo) , apio, verduras","es_un":"Carne","alergeno":"Si","precio":"15.30","prec_terraza":"16.00","nota_item":"","image":"794","creado_date":"2017-04-01","alergenos":[{"id":"1","name":"Gluten","code":"a01"},{"id":"27","name":"Apio","code":"a14"}]},{"DT_RowId":"row_330","site":"342800010","id_lang":"es","nombre":"Helado de frambuesa","condimentos":"frambuesa","es_un":"Postres","alergeno":"Si","precio":"4.50","prec_terraza":"5.25","nota_item":"","image":"792","creado_date":"2017-04-01","alergenos":[{"id":"1","name":"Gluten","code":"a01"},{"id":"7","name":"Pescado","code":"a04"},{"id":"17","name":"Mostaza","code":"a09"},{"id":"25","name":"Moluscos","code":"a13"}]}],"options":{"alergenos[].id":[{"label":"Altramuces","value":"23"},{"label":"Apio","value":"27"},{"label":"Cacahuetes","value":"9"},{"label":"Crustaceos","value":"3"},{"label":"Frutos de cascara","value":"15"},{"label":"Gluten","value":"1"},{"label":"Huevos","value":"5"},{"label":"Leche - lactosa","value":"13"},{"label":"Moluscos","value":"25"},{"label":"Mostaza","value":"17"},{"label":"Pescado","value":"7"},{"label":"Sesamo","value":"19"},{"label":"Soja","value":"11"},{"label":"Sulfitos - SO2","value":"21"}]},"files":{"files_chef_recomd":{"794":{"id":"794","site":"342800010","filename":"grilled-1631727_640.jpg","filesize":"70264","web_path":"\/upload_chef\/794.jpg","system_path":"\/home\/tripntry\/www\/upload_chef\/794.jpg","web_path_thumb1":"\/upload_chef\/thumb1\/342800010\/794.jpg","sys_path_thumb1":"\/home\/tripntry\/www\/upload_chef\/thumb1\/342800010\/794.jpg","web_path_thumb2":"\/upload_chef\/thumb2\/342800010\/794.jpg","sys_path_thumb2":"\/home\/tripntry\/www\/upload_chef\/thumb2\/342800010\/794.jpg"},"792":{"id":"792","site":"342800010","filename":"cakes-314378_640.jpg","filesize":"68309","web_path":"\/upload_chef\/792.jpg","system_path":"\/home\/tripntry\/www\/upload_chef\/792.jpg","web_path_thumb1":"\/upload_chef\/thumb1\/342800010\/792.jpg","sys_path_thumb1":"\/home\/tripntry\/www\/upload_chef\/thumb1\/342800010\/792.jpg","web_path_thumb2":"\/upload_chef\/thumb2\/342800010\/792.jpg","sys_path_thumb2":"\/home\/tripntry\/www\/upload_chef\/thumb2\/342800010\/792.jpg"},"793":{"id":"793","site":"342800010","filename":"cod-1252654_640.jpg","filesize":"80948","web_path":"\/upload_chef\/793.jpg","system_path":"\/home\/tripntry\/www\/upload_chef\/793.jpg","web_path_thumb1":"\/upload_chef\/thumb1\/342800010\/793.jpg","sys_path_thumb1":"\/home\/tripntry\/www\/upload_chef\/thumb1\/342800010\/793.jpg","web_path_thumb2":"\/upload_chef\/thumb2\/342800010\/793.jpg","sys_path_thumb2":"\/home\/tripntry\/www\/upload_chef\/thumb2\/342800010\/793.jpg"}}},"debugSql":[{"query":"SELECT  `id` as 'id', `site` as 'site', `id_lang` as 'id_lang', `nombre` as 'nombre', `condimentos` as 'condimentos', `es_un` as 'es_un', `alergeno` as 'alergeno', `precio` as 'precio', `prec_terraza` as 'prec_terraza', `nota_item` as 'nota_item', `image` as 'image', `creado_date` as 'creado_date' FROM  `chef_recomd` WHERE `site` = :where_0 AND `id_lang` = :where_1 ","bindings":[{"name":":where_0","value":"342800010","type":null},{"name":":where_1","value":"es","type":null}]},{"query":"SELECT DISTINCT  `chef_recomd`.`id` as 'dteditor_pkey', `alergenos`.`id` as 'id', `alergenos`.`name` as 'name', `alergenos`.`code` as 'code' FROM  chef_recomd as chef_recomd  JOIN `chef_recomd_alergenos` ON `chef_recomd`.`id` = `chef_recomd_alergenos`.`item_id`   JOIN `alergenos` ON `alergenos`.`id` = `chef_recomd_alergenos`.`alergeno_id` ","bindings":[]},{"query":"SELECT DISTINCT  `id` as 'id', `name` as 'name' FROM  `alergenos` ","bindings":[]},{"query":"SELECT  `id` as 'id', `site` as 'site', `filename` as 'filename', `filesize` as 'filesize', `web_path` as 'web_path', `system_path` as 'system_path', `web_path_thumb1` as 'web_path_thumb1', `sys_path_thumb1` as 'sys_path_thumb1', `web_path_thumb2` as 'web_path_thumb2', `sys_path_thumb2` as 'sys_path_thumb2' FROM  `files_chef_recomd` WHERE (`site` = :where_1 )","bindings":[{"name":":where_1","value":"342800010","type":null}]}]}
    
This discussion has been closed.