Wednesday, June 2, 2010

Re: Miles J Uploader help

Hey Miles,

Did you ever test this?

Just checking. I am going to try and maybe do a Set::extract??

Going to start tomorrow but thought I would check in.

Brad

On May 19, 11:37 am, Miles J <mileswjohn...@gmail.com> wrote:
> Its probably getting confused trying to load the data since both the
> file input and date input are arrays. I dont think I have ever tested
> with a date/time input, ill try it out.
>
> On May 19, 11:23 am,bradmaxs<b...@pezzano.com> wrote:
>
> > 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 <mileswjohn...@gmail.com> 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 <sam.sherl...@gmail.com> 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<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`",
> > > > > > >  
>
> ...
>
> 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: