I just want to upload a single pdf file using cakephp, here is my view called pdfadd.ctp:
<?php echo $this->Form->create('pdfadd1', array('enctype' => 'multipart/form-data'));?> <fieldset> <?php echo $this->Form->file('Document.submittedfile'); ?> </fieldset> <?php echo $this->Form->end(__('Submit'));?> Here is my conroller:
public function pdfadd(){ if ($this->request->is('post') || $this->request->is('put')) { //die(); $file = $this->request->data['Document']['submittedfile']; //$this->pdfadd1->save($this->request->data); move_uploaded_file($this->data['Document']['submittedfile']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . '/app/webroot/files/' . $this->data['Document']['submittedfile']['name']); } It gives me this error:
Warning (2): move_uploaded_file(D:/Program Files D/xampp/htdocs/app/webroot/files/Functions Package for email (1).pdf): failed to open stream: No such file or directory [APP\Controller\PagesController.php, line 29] Warning (2): move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Program Files D\xampp\tmp\php862.tmp' to 'D:/Program Files D/xampp/htdocs/app/webroot/files/Functions Package for email (1).pdf' [APP\Controller\PagesController.php, line 29] And also I want to rename the file to 1.pdf. The file should save in webroot/files.