my controller
public function add() {
$this->helpers = array('TinyMCE.TinyMCE');
$this->layout = 'adminpanel';
if ($this->request->is('post')) {
$this->Tour->create();
if ($this->Tour->save($this->request->data)) {
$this->Session->setFlash(__('Your possstt has been saved.'));
return $this->redirect(array('controller'=>'admin','action' => 'tour'));
}
$this->Session->setFlash(__('Unable to add your schedule.'));
}
my view file
echo $this->Form->create('Tour');
echo $this->Form->input('vartitle',array('class' => 'form-control','label' => 'Tour Title'));
// etc.................
echo $this->Form->input('varbigimg', array('type' => 'file'));
echo $this->Form->end('Save Post',array('class' => 'form-control'));
I already check model because image name are stored in database but I want to use that image. I want to save that image in any folder so help me. I am using new version thanks
So tell me how to store image in webroot folder and just save name in database field varbigimg field. I also want to display it on page too. So please solve my problem thanks
I am new in cakephp thanks
You need to move your uploaded file to a folder. Get the file info of your
$this->request->data
and move to a folder inwebroot
.There are many plugins for that. Like: Upload Plugin 2.0
Use following
Allows image/video data to be processed.
Inside controller
//HERE you need to specify same for thum
////HERE you need to specify same for thumbfield
//Update
//Specify input type in your code explicitely here.
Man , i get to you the needs to make it simply. First you need access the file in your controller, using $this->data['Tour']['varbigimg']; ok , it's your file. Ok, now you need send this file to webroot, you can use File Class of the cakephp http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html You can move and copy files to webroot using WWW_ROOT constraint, this constant get to you the correct path to webroot folder, if u need send to webroot img use IMAGES constant. Using, Folder/File and cakephp constants it's very easy to make your needs. If you need a more information about this, plz ask me and i create a real example to you. Tnx