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 <b...@pezzano.com> 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 <mileswjohn...@gmail.com> 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 <b...@pezzano.com> 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() - CORE/cake/dispatcher.php, line 204
> > > Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
> > > [main] - APP/webroot/index.php, line 83
> >
> > > Query: 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')
> >
> > > Seems like the array of image info isn't getting parsed?
> >
> > > Thanks for taking the time Miles.
> >
> > > Brad
> >
> > > On May 17, 8:11 pm, Miles J <mileswjohn...@gmail.com> wrote:
> >
> > > > Also forgot to say, this line should be "image" instead of "file",
> > > > since thats what you called it with the form helper.
> >
> > > > 'Uploader.Attachment' => array(
> > > >         'image' => array(
> >
> > > > On May 17, 7:57 pm, bradmaxs <b...@pezzano.com> wrote:
> >
> > > > > I am trying to implement miles j's uploader plugin and am having
> > > > > trouble making it work.
> >
> > > > > I keep getting this error: Warning (2): Invalid argument supplied
> for
> > > > > foreach()
> [APP/plugins/uploader/controllers/components/uploader.php,
> > > > > line 1006]
> >
> > > > > First and foremost I am using cakephp version 1.3 so I am not sure
> > > > > this is related because the plugin is tested through 1.2 something.
> >
> > > > > Here is what I did so far.
> >
> > > > > Added the uploader folder to the plugins folder.
> >
> > > > > Added this to my user_preferences_controller.php:
> >
> > > > > var $components = array('Uploader.Uploader');
> >
> > > > > var $actsAs = array(
> > > > >     'Uploader.Attachment' => array(
> > > > >         'file' => array(
> > > > >             'uploadDir'         => '/files/img_usericon/',   //
> Where to upload
> > > > > to, relative to app webroot
> > > > >             'dbColumn'          => 'image',  // The database column
> name to
> > > > > save the path to
> > > > >             'maxNameLength'     => 30,               // Max file
> name length
> > > > >             'overwrite'         => true,     // Overwrite file with
> same name if
> > > > > it exists
> > > > >             'name'              => '',               // The name to
> give the file (should be
> > > > > done right before a save)
> > > > >             'transforms'        => array()   // What
> transformations to do on
> > > > > images: scale, resize, etc
> > > > >         )
> > > > >     )
> > > > > );
> >
> > > > > Made my files folder 777.  Is this bad to do?
> >
> > > > > And my add action
> >
> > > > > function add($id = null) {
> > > > >                 if (!empty($this->data)) {
> > > > >                         $this->UserPreference->create();
> > > > >                         if ($data =
> $this->Uploader->upload('image')) {
> > > > >                         if
> ($this->UserPreference->save($this->data)) {
> > > > >
> $this->Session->setFlash(sprintf(__('The %s has been saved',
> > > > > true), 'user preference'));
> > > > >                                 $this->redirect(array('controller'
> => 'users', 'action' =>
> > > > > 'profile', $this->Auth->user('id')));
> > > > >                         } else {
> > > > >
> $this->Session->setFlash(sprintf(__('The %s could
> >
> > ...
> >
> > 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 cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.com>For
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to