Wednesday, January 19, 2011

urgently needed a help:image upload error

hi,
while uploading image i m getting an error like bellow

Undefined index: filedata [APP/controllers/images_controller.php,
line 19]

and

Cannot modify header information - headers already sent by (output
started at /home/satish/anand/cakephp/cake/libs/debugger.php:673)

//this is my controller 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']['filedata'];

// 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);
}
}
}
}
?>

please someone help me urgently

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate