Je reçois l'erreur suivante
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]
Le code que j'ai utilisé est le suivant
<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');?>
dans le contrôleur de formulaires function add($formid) [ ] echo "Imaage ".$this->data['Form']['image'];// affiche le tableau d'images
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();
}
}
L'instance pour le fichier ne fonctionne pas ? J'ai essayé de télécharger une image FILE et j'utilise une machine Ubuntu linux.