hi there,
i working on image uploading, but i m facing an error,
can any one solve the issue,

//this is my controller file image_controller.php

<?php
class ImagesController extends AppController {

        var $name = 'Images';
        var $helpers = array('Html', 'Form');
        var $components = array('Upload');

        function admin_upload() {

                if (empty($this->data)) {
                        $this->render();
                } else {
                        //$this->cleanUpFields();

                        // set the upload destination folder
                        $destination = 
realpath('../../app/webroot/img/uploads/');

                        // grab the file
                        $file = $this->data['Image']['images'];


                        // upload the image using the upload component
                        $result = $this->Upload->upload($file, $destination, 
null,
array('type' => 'resizecrop', 'size' => array('400', '300'), 'output'
=> 'jpg'));

                        if (!$result){
                                $this->data['Image']['images'] = 
$this->Upload->result;
                        } else {
                                // display error
                                $errors = $this->Upload->errors;

                                // piece together errors
                                if(is_array($errors)){ $errors = implode("<br 
/>",$errors); }

                                        $this->Session->setFlash($errors);
                                        $this->redirect('/images/upload');
                                        exit();
                                }
                        if ($this->Image->save($this->data)) {
                                $this->Session->setFlash('Image has been 
added.');
                                $this->redirect('/images/index');
                        } else {
                                $this->Session->setFlash('Please correct errors 
below.');
                                unlink($destination.$this->Upload->result);
                        }
                }
        }
}
?>

//this is my view admin_upload.ctp

<h2>Upload An Image</h2>
<?php echo $this->Form->create('Image',
array('action'=>'admin_upload'));?>
        <fieldset>
                <legend>
                        Images
                </legend>
                <ul>
                        <li>
                                <?php echo $form->label('Image/images', 
'Image:' );?>
                                <?php echo $form->file('Image/filedata');?>
                        </li>
                </ul>
        </fieldset>
        <p><input type="submit" name="add" value="Add Image" /></p>
</form>


pleaase help me as soon as possible

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