Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to upload the File to some location in cakephp
    primarykey
    data
    text
    <p>i am trying to use the File upload feature in my application ..</p> <p>i am having a Form with many fields of type Text,textarea and including File upload FIeld.</p> <p>I have kept a Submit button at the end of the Form which on click will submit the actual value of the textbox /textarea and even the value for the Field of type File upload.</p> <p>How to get the actual file that is uploaded and to save it in a location so that i can view the uploaded file later on ..</p> <p>The code that i have used is, Edit :</p> <p>i have added enctype in the Form tag but not working while submission</p> <pre><code> &lt;form method="post" action="/FormBuilder/index.php/forms/submit/93/13" id="ResultSubmit" enctype="multipart/form-data"&gt; &lt;div class="input file"&gt; &lt;label for="276"&gt;Choose Ur File To Upload&lt;/label&gt; &lt;input type="file" value="" style="width: 400px;" id="276" name="Choose ur file to upload"/&gt; &lt;/div&gt;&lt;br/&gt; &lt;div class="input text"&gt; &lt;label for="277"&gt;Name&lt;/label&gt; &lt;input type="text" value="" style="width: 200px;" id="277" name="Name"/&gt; &lt;/div&gt; &lt;br/&gt; &lt;div class="submit"&gt;&lt;input type="submit" value="submit"/&gt;&lt;/div&gt; &lt;/form&gt; </code></pre> <p>Action Submit in the Cakephp controller is</p> <pre><code> function submit($formid = null,$fillerid=null) { $this-&gt;data['Result']['form_id']=$formid; $this-&gt;data['Result']['submitter_id']=$fillerid; $this-&gt;data['Result']['submitter']=$this-&gt;Session-&gt;read('filler'); echo "submitter: ".$this-&gt;Session-&gt;read('filler'); $results=$this-&gt;Form-&gt;hasResults($this-&gt;data); echo http_build_query($_POST); if(empty($results)){ foreach ($_POST as $key =&gt; $value): if(is_array($value)){ $value = implode('', $_POST[$key]); $this-&gt;data['Result']['value']=$value; } else{ $this-&gt;data['Result']['value']=$value; } $this-&gt;data['Result']['form_id']=$formid; $this-&gt;data['Result']['submitter_id']=$fillerid; $this-&gt;data['Result']['label']=Inflector::humanize($key); $this-&gt;data['Result']['submitter']=$this-&gt;Session-&gt;read('filler'); $this-&gt;Form-&gt;submitForm($this-&gt;data); endforeach; $this-&gt;Session-&gt;setFlash('Your entry has been submitted.'); $this-&gt;Invite-&gt;updateAll(array('Invite.filled'=&gt;"'Yes'"),array('Invite.id'=&gt;"$fillerid")); }else{ $this-&gt;Session-&gt;setFlash('You have already filled the Form .'); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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