Hey Miles,

That worked for a straight upload action, thank you.

The Model Attachment is still not working for me though, still getting
the errors from the above post.

After looking closer it seems that my birthdate field is doing
something funny??

Warning (2): Invalid argument supplied for foreach() [APP/plugins/
uploader/controllers/components/uploader.php, line 1006]
Code | Context

        if (is_array($data)) {
            foreach ($data as $model => $fields) {
                foreach ($fields as $field => $value) {

$data   =       array(
        "month" => "05",
        "day" => "19",
        "year" => "2009"
)
$fields =       "05"
$model  =       "month"

I made it a hidden field and filled in the value myself and then just
got this error - probably from the component?

There was an error attaching this file!

Any ideas?  Thank you again for taking the time on this.

Brad

On May 18, 5:58 pm, Miles J <[email protected]> wrote:
> If you are using the latest uploader version, I believe its:
>
> if ($data = $this->Uploader->upload('UserPreference.fileName')) {
>
> On May 18, 11:14 am, Sam Sherlock <[email protected]> wrote:
>
> > Hi Brad
>
> > It is not a compatiblity issue with 1.3 - not able to speify the issue right
> > now but will try to compare your code with mine later today
>
> > but you may solve it by then :)
> > - S
>
> > On 18 May 2010 18:41, bradmaxs <[email protected]> wrote:
>
> > > I tried to just add it as an action in my controller and can't get a
> > > photo uploaded at all??
>
> > > permissions are set to 777 on both my files folder and img_usericon as
> > > well.
>
> > > Here is the user_preferences_controller.php
>
> > > var $components = array('Uploader.Uploader');
>
> > > in my beforeFilter
>
> > > $this->Uploader->uploadDir = 'files/img_usericon/';
> > > $this->Auth->allow('upload');
>
> > > the action
>
> > > function upload() {
> > >    if (!empty($this->data)) {
> > >        if ($data = $this->Uploader->upload('fileName')) {
> > >                 $this->Session->setFlash(sprintf(__('The %s has been
> > > saved',
> > > true), 'user photo'));
> > >                                 $this->redirect(array('controller' =>
> > > 'users', 'action' =>
> > > 'profile', $this->Auth->user('id')));
> > >        } else {
> > >                                 $this->Session->setFlash(sprintf(__('The 
> > > %s
> > > could not saved',
> > > true), 'user photo'));
> > >                                 $this->redirect(array('controller' =>
> > > 'users', 'action' =>
> > > 'profile', $this->Auth->user('id')));}
> > >    }
> > > }
>
> > > and upload.ctp
>
> > > <?php
> > > echo $this->element('errors', array('errors' => $errors));
> > > echo $form->create('UserPreference', array('url' => array('controller'
> > > => 'user_preferences', 'action' =>'upload'), 'type' => 'file'));
> > > echo $form->input('fileName', array('type' => 'file'));
> > > echo $form->end('Upload');
> > > ?>
>
> > > Not sure what I am doing wrong. Could it be 1.3?
>
> > > It is sending me back to my else redirect and giving me my not saved
> > > message?
>
> > > Thanks for any help.
>
> > > Brad
>
> > > On May 17, 11:05 pm, Miles J <[email protected]> wrote:
> > > > Let me do a few local tests. In the mean time, take a look at the
> > > > example controller in the plugin.
>
> > > > On May 17, 9:52 pm, bradmaxs <[email protected]> wrote:
>
> > > > > Hey Miles,
>
> > > > > Thanks for the fast reply.  For some reason i am only seeing your last
> > > > > post.  Google groups is acting funny for me.  I saw in the email
> > > > > summary that you left 2 messages but only see the one here.  I did see
> > > > > in the email summary that the first post you said I didn't need this
> > > > > in my controller if ($data = $this->Uploader->upload('image')) { so I
> > > > > took that out and also made the change to the attachment array to
> > > > > 'image'.  Should of caught that one myself but didn't so thank you.
>
> > > > > Now I am getting a bunch of errors - maybe this will help.
>
> > > > > Warning (2): Invalid argument supplied for foreach() [APP/plugins/
> > > > > uploader/controllers/components/uploader.php, line 1006]
> > > > > Code | Context
>
> > > > >         if (is_array($data)) {
> > > > >             foreach ($data as $model => $fields) {
> > > > >                 foreach ($fields as $field => $value) {
>
> > > > > $data   =       array(
> > > > >         "month" => "05",
> > > > >         "day" => "17",
> > > > >         "year" => "2009"
> > > > > )
> > > > > $fields =       "05"
> > > > > $model  =       "month"
>
> > > > > UploaderComponent::__parseData() - APP/plugins/uploader/controllers/
> > > > > components/uploader.php, line 1006
> > > > > UploaderComponent::__parseData() - APP/plugins/uploader/controllers/
> > > > > components/uploader.php, line 1016
> > > > > UploaderComponent::initialize() - APP/plugins/uploader/controllers/
> > > > > components/uploader.php, line 185
> > > > > Component::initialize() - CORE/cake/libs/controller/component.php,
> > > > > line 98
> > > > > Controller::startupProcess() - CORE/cake/libs/controller/
> > > > > controller.php, line 525
> > > > > Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 187
> > > > > Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
> > > > > [main] - APP/webroot/index.php, line 83
>
> > > > > Notice (8): Array to string conversion [CORE/cake/libs/model/
> > > > > datasources/dbo_source.php, line 731]
> > > > > Code | Context
>
> > > > > $model  =       UserPreference
> > > > > UserPreference::$name = "UserPreference"
> > > > > UserPreference::$validate = array
> > > > > UserPreference::$belongsTo = array
> > > > > UserPreference::$useDbConfig = "default"
> > > > > UserPreference::$useTable = "user_preferences"
> > > > > UserPreference::$displayField = "id"
> > > > > UserPreference::$id = false
> > > > > UserPreference::$data = array
> > > > > UserPreference::$table = "user_preferences"
> > > > > UserPreference::$primaryKey = "id"
> > > > > UserPreference::$_schema = array
> > > > > UserPreference::$validationErrors = array
> > > > > UserPreference::$tablePrefix = ""
> > > > > UserPreference::$alias = "UserPreference"
> > > > > UserPreference::$tableToModel = array
> > > > > UserPreference::$logTransactions = false
> > > > > UserPreference::$cacheQueries = false
> > > > > UserPreference::$hasOne = array
> > > > > UserPreference::$hasMany = array
> > > > > UserPreference::$hasAndBelongsToMany = array
> > > > > UserPreference::$actsAs = NULL
> > > > > UserPreference::$Behaviors = BehaviorCollection object
> > > > > UserPreference::$whitelist = array
> > > > > UserPreference::$cacheSources = true
> > > > > UserPreference::$findQueryType = NULL
> > > > > UserPreference::$recursive = 1
> > > > > UserPreference::$order = NULL
> > > > > UserPreference::$virtualFields = array
> > > > > UserPreference::$__associationKeys = array
> > > > > UserPreference::$__associations = array
> > > > > UserPreference::$__backAssociation = array
> > > > > UserPreference::$__insertID = NULL
> > > > > UserPreference::$__numRows = NULL
> > > > > UserPreference::$__affectedRows = NULL
> > > > > UserPreference::$_findMethods = array
> > > > > UserPreference::$User = User object
> > > > > $fields =       array(
> > > > >         "user_id",
> > > > >         "sex",
> > > > >         "birthdate",
> > > > >         "hometown",
> > > > >         "introduction",
> > > > >         "image",
> > > > >         "modified",
> > > > >         "created"
> > > > > )
> > > > > $values =       array(
> > > > >         "5",
> > > > >         "Male",
> > > > >         "2009-05-17",
> > > > >         "Los Angeles",
> > > > >         "Yo",
> > > > >         array(
> > > > >         "name" => "resume.jpg",
> > > > >         "type" => "image/jpeg",
> > > > >         "tmp_name" => "/tmp/phpfiQHs8",
> > > > >         "error" => 0,
> > > > >         "size" => 174644
> > > > > ),
> > > > >         "2010-05-17 21:49:24",
> > > > >         "2010-05-17 21:49:24"
> > > > > )
> > > > > $id     =       null
> > > > > $count  =       8
> > > > > $i      =       8
> > > > > $valueInsert    =       array(
> > > > >         "5",
> > > > >         "'Male'",
> > > > >         "'2009-05-17'",
> > > > >         "'Los Angeles'",
> > > > >         "'Yo'",
> > > > >         array(
> > > > >         "'resume.jpg'",
> > > > >         "'image/jpeg'",
> > > > >         "'/tmp/phpfiQHs8'",
> > > > >         "'0'",
> > > > >         "'174644'"
> > > > > ),
> > > > >         "'2010-05-17 21:49:24'",
> > > > >         "'2010-05-17 21:49:24'"
> > > > > )
> > > > > $fieldInsert    =       array(
> > > > >         "`user_id`",
> > > > >         "`sex`",
> > > > >         "`birthdate`",
> > > > >         "`hometown`",
> > > > >         "`introduction`",
> > > > >         "`image`",
> > > > >         "`modified`",
> > > > >         "`created`"
> > > > > )
>
> > > > > implode - [internal], line ??
> > > > > DboSource::create() - CORE/cake/libs/model/datasources/dbo_source.php,
> > > > > line 731
> > > > > Model::save() - CORE/cake/libs/model/model.php, line 1335
> > > > > UserPreferencesController::add() - APP/controllers/
> > > > > user_preferences_controller.php, line 41
> > > > > Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204
> > > > > Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
> > > > > [main] - APP/webroot/index.php, line 83
>
> > > > > Warning (512): SQL Error: 1054: Unknown column 'Array' in 'field
> > > > > list' [CORE/cake/libs/model/datasources/dbo_source.php, line 666]
> > > > > Code | Context
>
> > > > >             $out = null;
> > > > >             if ($error) {
> > > > >                 trigger_error('<span style="color:Red;text-
> > > > > align:left"><b>' . __('SQL Error:', true) . "</b> {$this->error}</
> > > > > span>", E_USER_WARNING);
>
> > > > > $sql    =       "INSERT INTO `user_preferences` (`user_id`, `sex`,
> > > `birthdate`,
> > > > > `hometown`, `introduction`, `image`, `modified`, `created`) VALUES (5,
> > > > > 'Male', '2009-05-17', 'Los Angeles', 'Yo', Array, '2010-05-17
> > > > > 21:49:24', '2010-05-17 21:49:24')"
> > > > > $error  =       "1054: Unknown column 'Array' in 'field list'"
> > > > > $out    =       null
>
> > > > > DboSource::showQuery() - CORE/cake/libs/model/datasources/
> > > > > dbo_source.php, line 666
> > > > > DboSource::execute() - CORE/cake/libs/model/datasources/
> > > > > dbo_source.php, line 256
> > > > > DboSource::create() - CORE/cake/libs/model/datasources/dbo_source.php,
> > > > > line 734
> > > > > Model::save() - CORE/cake/libs/model/model.php, line 1335
> > > > > UserPreferencesController::add() - APP/controllers/
> > > > > user_preferences_controller.php, line 41
> > > > > Dispatcher::_invoke() -
>
> ...
>
> read more »

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to