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 not be saved.
> Please, try again.', true), 'user preference'));
>                         }
>                 }
>
> }
>
> And my add.ctp
>
> <?php
> echo $this->Form->create('UserPreference', array('enctype' =>
> 'multipart/form-data'));?>
>         <fieldset>
>                 <legend><?php printf(__('Add %s', true), __('User Preference',
> true)); ?></legend>
>         <?php
>                 echo $this->Form->hidden('user_id', array('value' =>
> $loggedin['User']['id']));
>                 echo $this->Form->input('image', array('type' => 'file', 
> 'label' =>
> 'Upload Image', 'error' => false));
>                 echo $this->Form->input('sex', array('options' => array('Male'
> =>'Male', 'Female' => 'Female'), 'error' => false));
>                 echo $this->Form->input('birthdate', array('type' => 'date',
> 'minYear' => 1925, 'maxYear' => 2009, 'error' => false));
>                 echo $this->Form->input('hometown', array('error' => false));
>                 echo $this->Form->input('introduction', array('error' => 
> false));
>         ?>
>         </fieldset>
> <?php echo $this->Form->end(__('Submit', true));?>
>
>         }
>
> I am confused if I NEED validation for it to work or not.
>
> I ultimately want the user to be able to add preferences and upload
> the file at the same time and when the file is  uploaded I want the
> UserPreference Model's image column to reflect the images name.  If I
> can get this to work I then want to resize and possibly make changes
> to the image.
>
> Is this possible with this plugin or should I look for something else?
>
> Thank you,
>
> Brad
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 
> athttp://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