List Info

Thread: Re: $form->file() renders: Array to string conversion




Re: $form->file() renders: Array to string conversion
country flaguser name
United States
2007-06-21 06:36:35
Can you post your entire model,  I want to see your
$valdiate array.
Try removing the validation from the file field, if that
works, try
the new version of the upload behaviour (http://bin.cakephp.org/
saved/
20438).

On Jun 20, 9:05 pm, mastorna <mongi...gmail.com> wrote:
> I believe this topic has come up few times, but after
searching the
> archives, I'm at a complete loss at how to solve it. 
I'm doing a file
> upload and I repeatly receive the same error.
>
> Array to string conversion
[CORE/cake/libs/view/helper.php, line 296]
>
> so i've got an input type of file using the view and
formHelper:
>
> VIEW:
>
> $form->file(Model.name);  // in this case:
Mixtape.filename
> echo
$form->label('Mixtape.artist',"Artists:");
> echo $form->input('Mixtape.artist', array('div'
=> true, 'label' =>
> false, 'class'=>'required', 'error' => array( 0
=> 'Please provide a
> valid artist', 1 => 'The artist must have at least 2
or more
> characters' )));
>
> CONTROLLER:
>
> if ($this->Mixtape->save($this->data))
> {
>      $this->flash('Your post has been
saved.','/mixtape');
>
> }
>
> So when the controller passes this to the model, its
going to pass the
> file ($_FILES) as an array, which is understood.
>
>         var $actsAs = array('Upload' => array(
>                                 'filename' =>
array(
>                                                 'dir'
=> 'files/images',
>                                                
'overwrite_existing' => false,
>                                                
'create_directory' => false,
>                                                
'allowed_mime' => array('audio/mpeg','image/jpeg',
'image/
> pjpeg', 'image/gif', 'image/png'),
>                                                
'allowed_ext' => array('.mp3','.jpg', '.jpeg', '.png',
'.gif'),
>                                 )
>                         )
>         );
>
> When I hit submit, the data passes to the model and
cakePHP spits out
> out this error.  How do I solve for this?


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


Re: $form->file() renders: Array to string conversion
country flaguser name
United States
2007-06-27 00:42:44

I was getting this same issue. What fixed it for me was
making sure the app

dardosordi wrote:
> 
> 
> Can you post your entire model,  I want to see your
$valdiate array.
> Try removing the validation from the file field, if
that works, try
> the new version of the upload behaviour (http://bin.cakephp.org/
saved/
> 20438).
> 
> On Jun 20, 9:05 pm, mastorna <mongi...gmail.com> wrote:
>> I believe this topic has come up few times, but
after searching the
>> archives, I'm at a complete loss at how to solve
it.  I'm doing a file
>> upload and I repeatly receive the same error.
>>
>> Array to string conversion
[CORE/cake/libs/view/helper.php, line 296]
>>
>> so i've got an input type of file using the view
and formHelper:
>>
>> VIEW:
>>
>> $form->file(Model.name);  // in this case:
Mixtape.filename
>> echo
$form->label('Mixtape.artist',"Artists:");
>> echo $form->input('Mixtape.artist', array('div'
=> true, 'label' =>
>> false, 'class'=>'required', 'error' => array(
0 => 'Please provide a
>> valid artist', 1 => 'The artist must have at
least 2 or more
>> characters' )));
>>
>> CONTROLLER:
>>
>> if ($this->Mixtape->save($this->data))
>> {
>>      $this->flash('Your post has been
saved.','/mixtape');
>>
>> }
>>
>> So when the controller passes this to the model,
its going to pass the
>> file ($_FILES) as an array, which is understood.
>>
>>         var $actsAs = array('Upload' => array(
>>                                 'filename' =>
array(
>>                                                
'dir' => 'files/images',
>>                                                
'overwrite_existing' =>
>> false,
>>                                                
'create_directory' =>
>> false,
>>                                                
'allowed_mime' =>
>> array('audio/mpeg','image/jpeg', 'image/
>> pjpeg', 'image/gif', 'image/png'),
>>                                                
'allowed_ext' =>
>> array('.mp3','.jpg', '.jpeg', '.png', '.gif'),
>>                                 )
>>                         )
>>         );
>>
>> When I hit submit, the data passes to the model and
cakePHP spits out
>> out this error.  How do I solve for this?
> 
> 
> > 
> 
> 

-- 
View this message in context: http://www.nabble.com
/%24form-%3Efile%28%29-renders%3A-Array-to-string-conversion
--CORE-cake-libs-view-helper.php%2C-line-296--tf3955798.html
#a11318726
Sent from the CakePHP mailing list archive at Nabble.com.


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


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )