Hi,
i am trying to use the File upload feature in my application ..
i am having a Form with many fields of type Text,textarea and including File upload FIeld.
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.
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 ..
The code that i have used is, Edit :
i have added enctype in the Form tag but not working while submission
<form method="post" action="/FormBuilder/index.php/forms/submit/93/13" id="ResultSubmit" enctype="multipart/form-data">
<div class="input file">
<label for="276">Choose Ur File To Upload</label>
<input type="file" value="" style="width: 400px;" id="276" name="Choose ur file to upload"/>
</div><br/>
<div class="input text">
<label for="277">Name</label>
<input type="text" value="" style="width: 200px;" id="277" name="Name"/>
</div> <br/>
<div class="submit"><input type="submit" value="submit"/></div>
</form>
Action Submit in the Cakephp controller is
function submit($formid = null,$fillerid=null)
{
$this->data['Result']['form_id']=$formid;
$this->data['Result']['submitter_id']=$fillerid;
$this->data['Result']['submitter']=$this->Session->read('filler');
echo "submitter: ".$this->Session->read('filler');
$results=$this->Form->hasResults($this->data);
echo http_build_query($_POST);
if(empty($results)){
foreach ($_POST as $key => $value):
if(is_array($value)){
$value = implode('', $_POST[$key]);
$this->data['Result']['value']=$value;
}
else{
$this->data['Result']['value']=$value;
}
$this->data['Result']['form_id']=$formid;
$this->data['Result']['submitter_id']=$fillerid;
$this->data['Result']['label']=Inflector::humanize($key);
$this->data['Result']['submitter']=$this->Session->read('filler');
$this->Form->submitForm($this->data);
endforeach;
$this->Session->setFlash('Your entry has been submitted.');
$this->Invite->updateAll(array('Invite.filled'=>"'Yes'"),array('Invite.id'=>"$fillerid"));
}else{
$this->Session->setFlash('You have already filled the Form .');
}
}