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 <[email protected]> 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 <[email protected]> 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.organdhelp 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
> > athttp://groups.google.com/group/cake-php?hl=en
>
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected] 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 [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