ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Advice on fieldtypes - file upload fields when upgrading to 2.x

July 30, 2010 12:57pm

Subscribe [24]
  • #46 / Aug 29, 2011 7:44pm

    AdamSmith

    22 posts

    I have successfully updated to EE2 and ran the SQL query to fix all of my file paths.

    However I’m having trouble with the last step, running the php script to generate thumbnails. I’ve added the script to a template, with php enabled on output. And I’d double checked the server_path:

    <?php
    /* WARNING */
    //if you have a large number of files here
    //you may run into PHP max_execution_time or memory_limit errors
    
    //change this to the full server path to your upload directory WITH trailing slash
    $server_path = '/home/username/mydomain.com/images/products/';
    
    $this->EE->load->helper('file');
    $this->EE->load->library('filemanager');
    
    foreach (get_filenames($server_path) as $name)
    {
        if ( ! file_exists($server_path.'_thumbs/thumb_'.$name))
        {
            $this->EE->filemanager->create_thumb(
                array('server_path' => $server_path),
                array('name' => $name)
            );
        }
    }
    
    echo 'FINISHED THUMB CREATION';
    
    ?>

    However, I’m getting a page full of errors, and no thumbnails :(

    A PHP Error was encountered

    Severity: Notice

    Message: Undefined index: server_path

    Filename: libraries/Filemanager.php

    Line Number: 1173

    A PHP Error was encountered

    Severity: Notice

    Message: Array to string conversion

    Filename: helpers/file_helper.php

    Line Number: 328

    Any insight?

  • #47 / Aug 29, 2011 8:24pm

    Rob Sanchez

    335 posts

    What EE2 version are you on? I think things might’ve changed since I posted that solution.

  • #48 / Aug 29, 2011 8:29pm

    AdamSmith

    22 posts

    The latest version:  v2.2.2 - Build: date 20110801

    Do you know how they’ve changed?

  • #49 / Aug 29, 2011 8:43pm

    AdamSmith

    22 posts

    Actually I just found out 😊

    If you sync the upload directories via the File Manager, it will automatically create the thumbs for you.

  • #50 / Nov 18, 2011 2:38pm

    Brad K Morse

    178 posts

    Late to the party, but I recently wrote a couple scripts to automate assigning the appropriate filedir to each file, whether it was a regular field or matrix field.

    As well as setting the allowed directory for each custom file field, for file fields within a matrix field too: http://ellislab.com/forums/viewthread/203380/#952561

  • #51 / Jul 04, 2012 4:12pm

    gazettejournal

    8 posts

    Surely I must be doing something wrong, but after running Rob’s code I get this in the database:  https://ellislab.com/asset/images/team-photo/1
    I’m certain I’ll need to start over, and that’s ok, but I need to know where I messed up so I can get it right next time.

    UPDATE:
    OKay I figured it out. I just needed to use Adam’s version for matrix.

    THANK YOU!!!!!!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases