php - cakephp upload plugin no input parameters can be change -


i attached plugin cakephp project: https://github.com/josegonzalez/cakephp-upload.

it took me lot of time realise upload files webroot\files\model_name\filename folder, @ first thought no file uploaded. database like:

id|descr|filename|filepath

i try modify input parameters,but nothing happened copy file : webroot\files\model_name\filename on , on again.i tried empty cache not worked.

 public $actsas = array(     'upload.upload' => array(         'path' => '{root}{ds}webroot{ds}img{ds}{model}{ds}{field}{ds}',         'filename'=> array(      ) ); 

also:

        public $actsas = array(     'upload.upload' => array(         'filename'=> array(         'path' => '{root}{ds}webroot{ds}img{ds}{model}{ds}{field}{ds}',                     )     ) ); 

also:

     class user extends appmodel {         public $actsas = array(             'upload.upload' => array(                 'filename' => array(                     'fields' => array(                         'dir' => 'photo_dir'                     )                 )             )         );  } 

at point thought doesn't works @ all.so modifed filename got sql error,so must work until this:

'upload.upload' => array( 'filename' => array( 

i spent lot of time find solution(on sof,google everywhere).but not dont know why can not change upload folder..

update1: made small research:

class uploadbehavior extends modelbehavior {  public $defaults = array(     'rootdir' => null,     'pathmethod' => 'primarykey',     'path' => '{root}webroot{ds}files{ds}{model}{ds}{field}{ds}', .. 

however can not modify path parameter model,here can change , works well.

for file uploading sufficient raw php, create form attribute enctype="multipart/form-data" containing 1 or more inputs of type file , use simple php method "move_uploaded_file" save location prefer.

here example form:

<form action="yourscript.php" method="post" enctype="multipart/form-data">     <input type="file" name="filetoupload" id="filetoupload">     <input type="submit" value="upload file" name="submit"> </form> 

and php method:

move_uploaded_file($_files["filetoupload"]["tmp_name"], 'yourpreferredpath/yourfile') 

but in cakephp, instead of $_files must use $this->request->data, this:

$this->request->data["filetoupload"]["tmp_name"] 

for more information @ http://www.w3schools.com/php/php_file_upload.asp


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -