Yes i too need solution for this issue
On 6 Jul 2011 07:39, "elogic" <asymo...@elogicmedia.com.au> wrote:
>
> Hi All,
>
> I have setup a file upload feature for my application using the below
> plugin. Now that I have the csv uploading using an upload controller
> and model I now need to insert the csv into a mysql table. I haven't
> had much luck with the samples I have found online. Does anyone know
> how I can do this? I can get my client to name the fields however it
> needs to be done so that isn't an issue.
>
>
> MY UPLOADS_CONTROLLER
> -------------------------------------------------------------------------
> class UploadsController extends AppController
> {
>
>        var $name = 'Uploads';
>
>        // CSV UPLOAD
>        //
------------------------------------------------------------------
> >
>        function upload() {
>
>                        if (!empty($this->data))
>                        {
>                                $this->Upload->create();
>                                if($this->Upload->save($this->data))
>                                {
>                                        $this->Session->setFlash(__('The
file has been saved', true));
>                                        //print_r($this->data);
>                                        $thefilename =
 $this->data['Upload']['file']['name'];
>                                        echo $thefilename; // the uploaded
CSV FILE NAME!
>
>
>                                        // TO DO PROCESS UPLOADED FILE INTO
PROPERTIES DATABSE
>                                }
>                                else
>                                {
>                                        $this->Session->setFlash(__('The
file could not be saved. Please,
> try again.', true));
>                                }
>
>                        }
>        }
>
> }
> --------------------------------------------
>
> MY UPLOADS MODEL
> ---------------------------------------------------------
> <?php
> class Upload extends AppModel {
> var $name = 'Upload';
> var $actsAs = array(
>          'FileUpload.FileUpload' => array(
>                'uploadDir' => 'files',
>                'forceWebroot' => true, //if false, uploads will be saved
to
>
      //the uploadDir as a direct path.
>
      //default: true
>                /*
>                'fields' => array(
>                  'name' => 'file_name',
>                  'type' => 'file_type',
>                  'size' => 'file_size'
>                ),
>                */
>                'allowedTypes' => array(
>                  'csv' => array('text/csv', 'application/csv')
>                ),
>                'maxFileSize' => '1000000', //in bytes
>                'unique' => false, //uploaded files will overwrite existing
files
>                'fileNameFunction' => false, //execute sha1 on fileName if
required,
> not though
>          )
>        );
> }
> ------------------------------------------------------
>
>
> Thanks
>
>
>
>
> FILE UPLOAD PLUGIN:
http://www.webtechnick.com/blogs/view/221/CakePHP_File_Upload_Plugin
>
> --
> 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+unsubscr...@googlegroups.com For more options, visit this group
at http://groups.google.com/group/cake-php

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to