I'm using cakephp uploader 4.3.1
plugin from milesj.me
. I installed it using the composer
its working properly.
Now the problem is when i upload an image one entry is added to the database with image path but i couldn't find the image in the destination folder.
the Model->save
function is executing successfully.
I'm using cakephp 2x
EDIT
if i dont give destination directory the files will be uploaded to /files/uploads
directory and i can find the images there!!!!!!!!!!
but when i give destination as /img/uploads
i couldn't find.
Model Code
CustomImage.php
<?php
App::uses('AppModel', 'Model');
class CustomImage extends AppModel
{
public $name = 'CustomImage';
public $actsAs = array(
'Uploader.Attachment' => array(
'upload_image' => array(
'uploadDir' => '/img/uploads/',
'finalPath' => '/img/uploads/',
'dbColumn' => 'path',
'maxNameLength' => 30,
'overwrite' => true,
'stopSave' => true,
'allowEmpty' => false,
'transforms' => array(
array('method' => 'resize', 'width' => 240, 'dbColumn' => 'photo_thumb'))
)
),
'Uploader.FileValidation' => array(
'upload_image' => array(
'extension' => array('gif', 'jpg', 'png', 'jpeg'),
'required' => true
)
)
);
}
?>
Controller Code
MotionMakerController.php
class MotionMakerController extends AppController
{
public $helpers = array('Html','Form');
public $uses = array('CustomImage');
public function index()
{
}
public function add() {
if ($this->CustomImage->save($this->request->data, true)) {
echo "success";
}
}
}
View Code
add.ctp
<?php
echo $this->Form->create('CustomImage', array('type' => 'file'));
echo $this->Form->input('upload_image', array('type' => 'file'));
echo $this->Form->end('Submit');
?>
Please help me.
Try creating a global variable and replace it with "/img/uploads/". Ex :
define('UPLOAD_DIR', WWW_ROOT . '/img/uploads');