CakePHPにてファイルの保存ができずに困っています。
以下のコードを記述して実行しているのですが、画像が保存されない状態です。
何が原因かわからないので、質問させていただきます。
また、不足がございましたらお申しつけいただけると幸いです。
コード
Controller 【ImageController.php】 public function fileup(){ if ($this->request->is('post') || $this->request->is('put')) { if($this->Image->save($this->request->data)){ $path = IMAGES; $image = $this->request->data['Post']['image']; $this->Session->setFlash('画像を登録しました'); move_uploaded_file($image['tmp_name'], $path . DS . $image['name']); }else{ $this->Session->setFlash('画像が登録できませんでした'); } } } 【fileup.ctp】 <?php echo $this->Form->create('Post', array('type'=>'file', 'enctype' => 'multipart/form-data')); echo $this->Form->input('Post.image', array('label' => false, 'type' => 'file', 'multiple')); echo $this->Form->submit('登録する', array('name' => 'submit')); echo $this->Form->end(); ?>
回答2件
あなたの回答
tips
プレビュー