Hi,
i am getting the error as
Array to string conversion [CORE/cake/libs/file.php, line 96]
$path = array(
"name" => "23_50_11[1].gif",
"type" => "image/gif",
"tmp_name" => "/tmp/phpbBWxAT",
"error" => 0,
"size" => 25230
)
$create = false
$mode = 493
dirname - [internal], line ??
File::__construct() - CORE/cake/libs/file.php, line 96
FormsController::add() - APP/controllers/forms_controller.php, line 528
Object::dispatchMethod() - CORE/cake/libs/object.php, line 117
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 245
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 211
require - APP/webroot/index.php, line 88
[main] - CORE/index.php, line 61
Notice (8): Array to string conversion [CORE/cake/libs/file.php, line 97]
$path = array(
"name" => "23_50_11[1].gif",
"type" => "image/gif",
"tmp_name" => "/tmp/phpbBWxAT",
"error" => 0,
"size" => 25230
)
$create = false
$mode = 493
is_dir - [internal], line ??
File::__construct() - CORE/cake/libs/file.php, line 97
FormsController::add() - APP/controllers/forms_controller.php, line 528
Object::dispatchMethod() - CORE/cake/libs/object.php, line 117
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 245
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 211
require - APP/webroot/index.php, line 88
[main] - CORE/index.php, line 61
Warning (2): basename() expects parameter 1 to be string, array given [CORE/cake/libs/file.php, line 98]
The code that i have used is,
<h1>Form Fill</h1>
<?=$form->create('Form',array('type'=>'file'));?>
<?=$form->input('date',array('label'=>'Publication Date '));?>
<?=$form->input('headline');?>
<?=$form->input('content');?>
<?=$form->input('image',array('type'=>'file'));?>
<?=$form->end('Submit');?>
in the Formscontroller function add($formid) { echo "Imaage ".$this->data['Form']['image'];// shows me the Imaage Array
if ($this->data['Form']['image']) {
$file = new File($this->data['Form']['image']);// this is not working
//$ext = $file->ext();
//echo "Extension ".$ext;
echo "Fiel ".$file;
$date = $this->data['Form']['date'];
$filename = $date['year'].'-'.$date['month'].'-'.$date['day'].'-form-image.'.'gif';
$data = $file->read();
echo "Data ".$data;
$file->close();
$file = new File(WWW_ROOT.'/img/'.$filename,true);
$file->write($data);
$file->close();
}
}
Instance for File is not working?? Please help me . actually i m trying to upload the image FIle and i m using Ubuntu linux machine ..