Reputation: 65
i m new to cake php and tried to use meioupload for uploading file.,
searched for a complete steps., but i m not sure whether i read the full docs..
so here i m ., i ll discuss the things i did.,
from this link http://www.meiocodigo.com/projects/meioupload/
i created a table named "products"
CREATE TABLE products
(
id
int(8) unsigned NOT NULL auto_increment,
name
varchar(255) default NULL,
description
text default NULL,
price
double default NULL,
picture
varchar(255) default NULL,
dir
varchar(255) default NULL,
mimetype
varchar(255) NULL,
filesize
int(11) unsigned default NULL,
created
datetime default NULL,
modified
datetime default NULL,
PRIMARY KEY (id
) )
And then after adding the "$actAs" var in my model ., it looks like
`
Class product extends AppModel{
public $name="Product";
var $actsAs = array(
'MeioUpload' => array(
'picture' => array(
'dir' => 'uploads',
'create_directory' => true,
'max_size'=>'10 Mb',
'allowed_mime' => array('image/jpeg', 'image/pjpeg', 'image/png'),
'allowed_ext' => array('.jpg', '.jpeg', '.png'),
'thumbsizes' => array(
'normal' => array('width'=>200, 'height'=>200),
),
'default' => 'default.jpg',
)
)
);
} `
And uploaded MeioUploadBehavior.php file inside Model->Behaviour->MeioUploadBehavior.php from https://github.com/jrbasso/MeioUpload/blob/master/Model/Behavior/MeioUploadBehavior.php
My controller looks like
Class productscontroller extends AppController{
public $name="Products";
public function beforeFilter(){
$this->layout="admin";
}
public function admin_upload(){
}
}
And my view file from view->products->admin_upload.ctp
<?php
echo $this->Form->create('Product', array('type' => 'file'));
echo $this->Form->input('picture', array('type' => 'file'));
echo $this->Form->input('dir', array('type' => 'hidden'));
echo $this->Form->input('mimetype', array('type' => 'hidden'));
echo $this->Form->input('filesize', array('type' => 'hidden'));
echo $this->Form->end('Submit');
?>
when i run localhost/test/cake/admin/products/upload
i see the form with filefield ans submit button.,
and when i choose a image and submit., the form is successfully submitted and only a empty folder is created inside webroot->uploads->"thumb". No images moved to uploads and also thumb folder.,
And also there is data inserted in the table as well..
Do i need the save the data manually in my action !?
Kindly help.
Many Thanks.
Upvotes: 0
Views: 1325
Reputation: 3
Yes, looks like your controller's action is empty. Try saving the data that was submitted from the form using the model's save()
method. This will trigger MeioUpload to save the file that was uploaded with the form.
It also looks like you're using CakePHP 2.x, I suggest you qualify the plugin as 'MeioUpload.MeioUpload'
in the $actsAs
property of your model. Make sure you give proper write and execute permissions on the uploads
folder in your webroot.
Source: I'm building my own website with the MeioUpload plugin.
Upvotes: 0