On Fri, Jan 4, 2013 at 10:14 AM, Karl Smith <barnun...@hotmail.com> wrote:
>
> All I need from this array is the file name. Now with that said, I read alot
> of articles online about saving files to a database. Some people think it is
> better to save to the file system rather than the database. In my case I
> think the best thing for me to do is save the file in my db. My only
> question is "If I save the files to my database will it affect the
> performance of my website over time?"

Well, if you don't expect to have millions of files, or use slave
databases, go ahead and use BLOB. Personally, I'd avoid it.

> Now as far as my view goes..do I need to add an input for user_id and
> coverage_id as hidden fields?

The user_id you can add manually after the upload with
$this->Auth->user('id') but for coverage_id you can either use a
hidden form field or add that data to the array before saving as well.
Either way, you'll need to know what the coverage_id is so you should
pass it to the action in the first place:

echo $this->Html->link(
        'upload spreadsheet',
        array(
                'controller' => 'Coverages',
                'action' => 'processSpreadsheet',
                'coverage_id' => $xxx
        )
);

Router::connect(
        '/spreadsheet/upload/:coverage_id', // or whatever suits you
        array(
                'controller' => 'Coverages',
                'action' => 'processSpreadsheet'
        ),
        array(
                'coverage_id' => '[0-9]+',
                'pass' => array('coverage_id')
        )
);


public function processSpreadsheet($coverage_id = null)
{
        if ($this->request->is('post'))
        {
                // handle upload, save, and redirect            
        }
        
        // If all goes well upon submit you won't reach here
        // but will always arrive here on first invocation.
        // You should probably check here that $coverage_id isn't empty.
        
        $this->set(compact('coverage_id'));
}
        
        
Then create a hidden form field for the Spreadsheet.coverage_id var

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply via email to