Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8454187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:57:34+00:00 2026-06-10T11:57:34+00:00

I have a site in cakephp 2 and I want to upload a file

  • 0

I have a site in cakephp 2 and I want to upload a file with the plugin Uploader of Miles J.
But return me this error:
Column not found: 1054 Unknown column ‘Array’ in ‘field list’

SQL Query:

UPDATE `db148147_trimalcione`.`ingredient_images` 
SET 
    `id` = 6, 
    `filename` = Array, 
    `ingredient_id` = 8, 
    `modified` = '2012-08-21 23:01:13' 
WHERE `db148147_trimalcione`.`ingredient_images`.`id` = '6' 

Why?
I have create a table ingredient_images where I have the column filename.
This is my Model:

<?php
class IngredientImage extends AppModel {
    public $name = 'IngredientImage';
    public $useTable = 'ingredient_images';

    public $actsAs = array (
        'Uploader.Attachment' => array (
            'filename' => array(
                'name'      => 'setNameAsImgId',    // Name of the function to use to format filenames
                'saveAsFilename' => true,
                // 'baseDir'    => '',              // See UploaderComponent::$baseDir
                'uploadDir' => '/files/ingredient_images/', // See UploaderComponent::$uploadDir
                'dbColumn'  => 'filename',          // The database column name to save the path to
                'defaultPath'   => 'default.png',   // Default file path if no upload present
                'maxNameLength' => 20,              // Max file name length
                'overwrite' => true,                // Overwrite file with same name if it exists - Se si effettua un transform è da usare al suo interno altrimenti c'è un override a false
                'stopSave'  => true,                // Stop the model save() if upload fails
                'allowEmpty'    => true,            // Allow an empty file upload to continue
                'transforms'    => array (
                    array('method' => 'resize', 'width' => 160, 'height' => 160, 'dbColumn' => 'filename', 'append' => false, 'overwrite' => true)
                )
            )
        ),
        'Uploader.FileValidation' => array (
            'filename' => array (
                'maxWidth'  => array (
                    'value' => 1280,
                    'error' => 'La lunghezza dell\'avatar non deve superare i 1280 pixel'
                ),
                'maxHeight' => array (
                    'value' => 1280,
                    'error' => 'L\'altezza dell\'avatar non deve superare i 1280 pixel'
                ),
                'extension' => array (
                    'value' =>  array('gif', 'jpg', 'png', 'jpeg'),
                    'error' => 'Il formato dell\'avatar deve essere una GIF, JPG o PNG'
                ),
                'filesize'  => array (
                    'value' => 5242880,
                    'error' => 'La dimensione dell\'avatar non deve superare i 500kB'
                )
            )
        )
    );

    public $belongsTo = array(
        'Ingredient' => array(
            'className'     => 'Ingredient',
            'foreignKey'    => 'ingredient_id',
            'conditions'    => '',
            'order'         => ''
        )
    );

    public function setNameAsImgId ($name, $field, $file) {
        /**
        * Format the filename a specific way before uploading and attaching.
        * 
        * @access public
        * @param string $name   - The current filename without extension
        * @param string $field  - The form field name
        * @param array $file    - The $_FILES data
        * @return string
        */
        // devo ricavare l'id dell'immagine appena creata per rinominare il file

        return $this->id;
    }
}

?>

This is my controller:

CakePlugin::load('Uploader');
App::import('Vendor', 'Uploader.Uploader');
//.. my action
   $this->request->data['IngredientImage']['ingredient_id'] = $this->Ingredient->id;
$this->Ingredient->IngredientImage->save($this->request->data
//..

This is my view:

echo $this->Form->create('Ingredient', array ('class' => 'form', 'type' => 'file')); 
echo $this->Form->input('IngredientImage.id', array ('type'=>'hidden', 'value'=> $ingredient[0]['IngredientImage']['id'],'label'=> false, 'id' => 'IngredientImage.id'));
    echo $this->Form->input('IngredientImage.filename', array('type' => 'file'));
echo $this->Form->submit('Modifica', array('id'=>'edit'));
echo $this->Form->end();

Help me please

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:57:36+00:00Added an answer on June 10, 2026 at 11:57 am

    Check what it prints with pr($this->request->data); You will find an array for the filename index. Let’s suppose you are getting the filename at $this->request->data['IngredientImage'][filename']['actual_filename']. Then you can manipulate it using:

    CakePlugin::load('Uploader');
    App::import('Vendor', 'Uploader.Uploader');
    //.. my action
    $this->request->data['IngredientImage']['ingredient_id'] = $this->Ingredient->id;
    $this->request->data['IngredientImage']['filename'] = $this->request->data['IngredientImage']['filename']['actual_filename'];
    $this->Ingredient->IngredientImage->save($this->request->data)
    //..
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site set up using CakePHP and MySQL and I want to
I have a site developed in cakephp 2 and I want that into my
Hi I have a site develop in cakephp. I want to connect my cakephp
I have simple cakephp site. I want to track the downloads of the files
I have a site developed in cakephp 2.0, I want to make a relation
I have used Auth component in my cakephp site. I want to check whether
I'm building a site with CakePHP, but this question is more about solving an
I have cakephp installed in the root directory. site.com/ i want to install wordpress
I have a site developed in cakephp 2.0 and I want to see, when
I have a multi language site (German & English) in cakephp . But here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.