how to upload the File to some location in cakephp -


I am trying to use the file upload feature in my application.

Forming text with text, with many types of text, texture and file upload file.

I have submitted a form that after the click for the actual value of the text box / Textaria and even the value file upload type.

How to obtain the uploaded original file and save it to a location, so that I can see the uploaded file later ..

The code I have used , That is: Edit:

I've added an antipart in the form tag, but

   & Lt; / Div & gt; & Lt; Br / & gt; & Lt; Div class = "input text" & gt; & Lt; Label = "277" & gt; Name & lt; / Label & gt; & Lt; Input type = "text" value = "" style = "width: 200px;" Id = "277" name = "name" /> & Lt; / Div & gt; & Lt; Br / & gt; & Lt; Div class = "submit" & gt; Input type = "submit" value = "submit" gt; & Gt; / Div & gt; & Lt; / Form & gt;  

Take action in the CakeFop Controller

  submit the function ($ 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-> Read ('fill'); Echo "Presenter:" $ This- & gt; Session-> Read ('supplement'); $ Result = $ this- & gt; Form & gt; HasResults ($ this-> data); Echo http_build_query ($ _ POST); If ($ (value => $ value) = {$ value = $ implicit} {foreach ($ key = & gt; $ value as $ _POST): if (is_array ($ value)) {$ value = $ ($ $) ; $ This- & gt; Data ['result'] ['value'] = $ value; } And {$ this- & gt; Data ['result'] ['value'] = $ value; } $ This- & gt; Data ['result'] ['form_id'] = $ formid; $ This- & gt; Data ['result'] ['submitter_id'] = $ fillerid; $ This- & gt; Data ['result'] ['labels'] = inflector :: human ($ key); $ This- & gt; Data ['result'] ['submitter'] = $ this- & gt; Session-> Read ('fill'); $ This- & gt; Form & gt; SubmitForm ($ this-> data); Endforeach; $ This- & gt; Session-> Set Flash ('Your submission has been submitted.'); $ This- & gt; Invite-> UpdateAll (array ('Invite.filled' =>; '' 'yes''), array ('Invite.id' => '$ fillerid')); } And {$ this- & gt; Session-> Set Flash ('You have already filled the form.'); }}  

In /app/models/upload.ctp:

 Save first () (if (empty! ($ This-> Data ['Upload'] ['File']) & amp; is_uploaded_file ($ this- & gt; Data ['Upload '' ['File'] ['tmp_name'])) {if Move !, (Move-uploaded_file ($-- [[upload '] [' file '] [' tmp_name '],' some_location / '. This' & gt; data ['upload'] ['file'] ['name'])) {return false;} $ this-> data ['upload'] ['name'] = $ this- & Data [] '[upload'] ['file'] ['name']; $ this-> data ['upload'] ['type'] = $ this-> data ['upload' ] ['file type' ]; ['Size'] ['size'] = $ this- & gt; data ['upload'] ['file'] ['size'];} back true;} < Add /app/controllers/uploads_controller.php: 

  function in / code>  

(if (! (Empty ($ - this-> data))! {If ($-> this-> upload-> Save ($ this-> Data)) {$ this-> Session-> Set Flash ('File Upload Successful.'); $ $ - & gt; Redirect ('/ upload'); }}}

App / ideas / upload / add.ctp:

  counterpart $ form-> Create ('Upload'); Counterpart $ form-> Input ('Upload.File', array ('type' = & gt; 'file')); Counterpart $ form-> Submit ('Upload File'); Counterpart $ form-> And ();  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -