Posting my solution.

function edit($id = null)
{
        [...]

        if (!empty($this->data))
        {
                $img = $this->data['Model']['image']; // save file
upload array into a variable before sanitizing

                $this->data = Sanitize::clean($this->data); // perform
sanitization

                if ($this->Model->save($this->data))
                {
                        // clean data has now been saved.

                        // file upload logic, using the array we saved before
                        if (!is_uploaded_file($img['tmp_name']))
                        {
                                [...] // etc etc
                        }
                }
        }
}

No problems encountered using this approach.



On May 20, 9:38 am, Michele Ferri <zomgs...@gmail.com> wrote:
> The file uploads are working fine without Sanitize::clean(). The only
> solution I see is to handle the file validation/copy logic before
> executing the sanitization. I'm puzzled.
> Maybe I should mention that I'm running on my local windows machine
> using XAMPP. But all the php.ini upload-related variables are set...
>
> On May 19, 8:00 pm, calvin <cal...@rottenrecords.com> wrote:
>
>
>
> > Were the file uploads working before you used Sanitize::clean? Because
> > cake doesn't handle file uploads automatically. Aside from having to
> > set array('type'=>'file') in your $form->create() statement, you also
> > need to move/save the uploaded file yourself.
>
> > Unless you're manually moving the file, either to a permanent upload
> > directory or into a database or something, the web server (and cake)
> > has no way of knowing what you want to do with the file. It'll just
> > sit in the temp directory until the script terminates, at which point
> > the file will be deleted.
>
> > On May 19, 3:37 am, Michele Ferri <zomgs...@gmail.com> wrote:
>
> > > Hello.
>
> > > I'm using Sanitize::clean for cleaning the $this->data arrays in the
> > > controllers before saving them to the db.
>
> > > example
> > > if (!empty($this->data))
> > > {
> > >         $this->data = Sanitize::clean($this->data);
> > >         [...]
>
> > > }
>
> > > The problem is that if a form contains a file input, the file is not
> > > uploaded. The file array is correctly populated after the post (with
> > > tmp_name and everything), but the physical file is not present in the
> > > upload folder.
>
> > > Is there any workaround for this?
>
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers 
> > > 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 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 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 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