Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you need to save the data before you do the moving of the image, try this..</p> <pre><code> if ($this-&gt;Product-&gt;save($this-&gt;request-&gt;data)) //error here { $this-&gt;Session-&gt;setFlash(__('The product has been saved')); $this-&gt;redirect(array('action' =&gt; 'index')); $this-&gt;request-&gt;data['Product']['seller_id'] = $seller_id; } if(move_uploaded_file($this-&gt;request-&gt;data["Product"]["image"]["tmp_name"],WWW_ROOT."/img/uploads/" . $this-&gt;data["Product"]["image"]["name"]) == true) { $this-&gt;data["Product"]["image"] = $this-&gt;data["Image"]["image"]["name"]; } } </code></pre> <p>Hope it works for you</p> <p>Heres an example of how I've previously achieved a file upload, try using it as a guideline I suggest keeping it simple, also if you want to limit file types I suggest doing this in the MODEL. </p> <pre><code>public function add() { if($this-&gt;request-&gt;is('post')){ $file = $this-&gt;request-&gt;data['Upload']['file']; if($this-&gt;Upload-&gt;save($this-&gt;data) &amp;&amp; move_uploaded_file($file['tmp_name'],APP.'webroot/files/uploads'.DS.$this-&gt;Upload-&gt;id.'.mp4')) { $this-&gt;Session-&gt;setFlash('&lt;p class="uploadflash"&gt;The upload has been saved&lt;/p&gt;', true); $this-&gt;redirect(array('controller'=&gt;'Uploads', 'action' =&gt; 'watch', $this-&gt;Upload-&gt;id)); } else { $this-&gt;Session-&gt;setFlash('&lt;p class="loginerror"&gt;The upload could not be saved, mp4 files can be saved only.&lt;/p&gt;', true); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload