Anyone can help me??

I try to upload an image but after i clickn on submit button, i will
get this error.
"Warning (2): Cannot modify header information - headers already sent
by (output started at C:\xampplite\htdocs\myweb\app\controllers
\uploads_controller.php:1) [CORE\cake\libs\controller\controller.php,
line 742]"

//uploads_controller.php


    <?php
    class UploadsController extends AppController {
        var $name = 'Uploads';

        function index() {
            $screenshotError = $this->data['Upload']['screenshot']
['error'];
            $mimeType        = trim($this->data['Upload']['screenshot']
['type']);
            $this->set('showImage', 0);

            if ($screenshotError == 0) {
                $screenshot = new File($this->data['Upload']
['screenshot']['tmp_name']);

                if (!strstr($mimeType,'image')) {
                    $this->set('error', 'Unsupported screenshot format
or filesize too large.');
                } else {
                    $fileName     = $this->data['Upload']['screenshot']
['name'];
                    $uploadFolder = 'files/'.$fileName;
                    move_uploaded_file($this->data['Upload']
['screenshot']['tmp_name'],$uploadFolder);
                    if(file_exists($uploadFolder))  {
                        $this->set('image',$fileName);

                        /* ADD THESE LINES IN YOUR CODE*/
                        $this->data['Upload']['name'] = 'your name';
                        $this->data['Upload']['screenshot'] =
$fileName;
                        $this->data['Upload']['link'] = $fileName;
                        $this->data['Upload']['link1'] =
$uploadFolder;
                        $this->data['Upload']['link2'] =
$uploadFolder;
                        $this->data['Upload']['date_posted'] = time();
                        $this->Upload->create();
                        /* ADD THESE LINES IN YOUR CODE*/

                        $this->Upload->save($this->data);
                        $this->set('showImage', 1);
                        $this->redirect('/uploads/index');
                    }
                }

                if (!empty($fileName)) {
                    $this->data['Upload']['screenshot_path'] =
$uploadFolder;
                } else {
                    $this->data['Upload']['screenshot_path'] = '';
                }
            }
        }

        function delete($image = null) {
            if (!$image) {
                $this->set('errMsg', 'sorry invalid link');
            } else {
                unlink("files/{$image}");
                $this->redirect('/uploads/index');
            }
        }

    }





//upload.php

<?php

class Upload extends AppModel{

    var $name="Upload";


}

-- 
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
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to