Does anyone have an example on how to upload and process files in cakephp 1.3
I'm currently doing some test, without views (print_r), but I can't seem grab the contents of a file. I was able to grab the file name using $this->param['filename']
, but that's it.
Also, I'm new to cake, but I am working on an old application using the old cakephp framework. Can someone show me the process in uploading a file in cakephp?
I've seen some examples using $this->data
, but that doesn't yield any results for me.
Step 1
Create the form like this
echo $this->Form->create('modelname', array('enctype' => 'multipart/form-data'));
echo $this->Form->file('fieldname', array('type'=>'file'));
$this->Form->end(__('Submit'));
Step 2 in controller
move_uploaded_file($this->request->data['modelname']['fieldname']['tmp_name'],WWW_ROOT.'/foldertosave/filename.extension');
make sure you have permission to move the file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.