happened. Use a behavior for validation or use my plugin.
https://github.com/milesj/cake-uploader
And an example model on how to use it.
https://github.com/milesj/cake-uploader/blob/master/tests/models/upload.php
On Apr 27, 11:18 am, func0der <funco...@live.com> wrote:
> Hey guys,
>
> i'm having a file upload here.
> I'm using "afterSave" to place the uploaded file in the filesystem.
>
> function afterSave($created){
> //get the entry id
> $this->data['DataFile']['id'] = $this->getInsertId();
> if(!$this->saveDataFile($this->data)){
> $this->delete($this->data['DataFile']['id']);
> $this->data['DataFile']['data_file'] = array();
> $this->validates();
> }
> }
>
> "saveDataFile" is a function which tries to places the uploaded file
> in the file system and returns false in case of copy fails.
>
> If the copy should fail i delete the record from the database and set
> the "data_file" index which normally cotains the uploaded file
> information to an empty array. This is because i want the validation
> to fail so the file upload field gets an error message while
> rendering.
>
> The problem now is that the upload form does NOT! contain the
> validation error message for that particular field.
>
> Do you know what i am doing wrong?
>
> Greetings
> func0der
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
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
No comments:
Post a Comment