Wednesday, February 6, 2013

Cakephp download function not working

I am struggling with a download functionality for cakephp2.x. Here is what i am trying to achieve.

I am uploading my files to a folder named procedures_uploads after i upload the file i should be able to download it.

Currently when i upload the file from my add.ctp its not redirecting to the index.ctp and when i view the index.ctp manually its not inserting any record in the table . Below is my code for the download functionality and the add function

/** download functionality */

function download($id = null) {
    $adminProcedure = $this->AdminProcedure->findById($id);
        $this->viewClass = 'Media';
            $filename = $adminProcedure['AdminProcedure']['filename'];
                $this->set(array(
                    'id' => $adminProcedure['AdminProcedure']['id'],
                        'name' => substr($filename, 0, strrpos($filename, '.')),
                            'extension' => substr(strrchr($filename, '.'), 1),
                                'path' => APP.'procedures_uploads'.DS,
                                    'ext'=>'pdf',
                                        'download' => true,

)); }

And this is how i am saving the data in my add function

if ($this->uploadFile() && $this->AdminProcedure->save($this->request->data))

Does anyone know how to solve this proplem?

your assistance would be greatly appreciated.

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: