Hi I am following this uploader plugin to implement simple file upload
on my site:

http://www.milesj.me/resources/script/uploader-plugin

but the problem is that when I press the upload button call to a
unknown action add is made, I dont have any action by the name of add,
here is my code:

After log in user is directed to index.cpt which has the option to
upload score:

/////////////////////////
index.cpt
////////////////////////
<p>Hello, <?php echo($user['first_name'] . ' ' . $user['last_name']); ?
></p>
<p>Welcome to Game Web Site</p>
<ul>
<li><?php echo $html->link('Downloads',array('action'=>'downloads')); ?
></li>
<li><?php echo $html->link('Upload Score',array('action'=>'upload')); ?
></li>
<li><?php echo $html->link('logout', array('action' => 'logout')); ?></
li>
</ul>

On clicking Upload score link upload action is called

////////////////////////
upload.cpt
//////////////////////

<?php
    echo $form->create('User',array('type'=>'file'));
    //echo $form->file('File');
    echo $form->input('aiman', array('type' => 'file'));

    //echo $form->submit('Upload');
    echo $form->end('Upload2');
?>

now when I press upload2 button I get the following error:
////////////////////
Missing Method in UsersController
Error: The action add is not defined in controller UsersController

Error: Create UsersController::add() in file: app/controllers/
users_controller.php.

<?php
class UsersController extends AppController {

        var $name = 'Users';


        function add() {

        }

}
?>
///////////////////

Here is my controller:

<?php


class UsersController extends AppController
{
    var $name = 'Users';
    var $helpers = array('Html', 'Form');
    var $components = array('Uploader.Uploader');

    function register()
    {
                if (!empty($this->data))
                {
                        $this->data['User']['password'] = 
md5($this->data['User']
['password']);
                        if ($this->User->save($this->data))
                                {
                                        $this->Session->setFlash('Your 
registration information was
accepted');
                                        $this->Session->write('user', 
$this->data['User']['username']);

                                        $this->redirect(array('action' => 
'index'), null, true);
                                }
                        else {
                                        $this->data['User']['password'] = '';
                                        $this->Session->setFlash('There was a 
problem saving this
information');
                                 }
                }
    }



   function login()
    {
                if ($this->data)
                {
                        $results = 
$this->User->findByUsername($this->data['User']
['username']);
                        if ($results && $results['User']['password'] == 
md5($this-
>data['User']   ['password']))
                                {
                                        $this->Session->write('user', 
$this->data['User']['username']);
                                        $this->redirect(array('action' => 
'upload'), null, true);
                                }
                        else {
                                        $this->set('error', true);
                                 }
                }
    }



   function logout()
    {
                $this->Session->delete('user');
                $this->redirect(array('action' => 'login'), null, true);
    }


    function index()
    {
                $username = $this->Session->read('user');
                if ($username)
                {
                        $results = $this->User->findByUsername($username);
                        $this->set('user', $results['User']);
                }
                else {
                        $this->redirect(array('action' => 'login'), null, true);
                         }
    }



    function downloads()
    {
    }



   function upload()
    {

                if (!empty($this->data))
                  {
                        if ($data = $this->Uploader->upload('nam'))
                         {
                        // nam is the file name
                //var_dump($this->data); print '<br/>';
                                
$this->redirect(array('action'=>'login'),null,true);
                        }
          }

    }

}
?>


Please Help me to uplaod this file .

Thanks

-- 
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