0

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.

vijay
  • 65
  • 3
  • 12

1 Answers1

0

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.

OJ Tibi
  • 3
  • 2
  • Yes i m using CakePHP 2.x. And as u mention when i save() through my method i saw the entry added in Table and image moved to the "uploads" directory. But there is no thumbnail generated ., i tried extracting phpThumb into my Vendor folder..but same result.. – vijay Mar 19 '12 at 08:17
  • Looks like you're all good with the phpThumb vendor. I edited my answer above, did you forget to fix your `uploads` folder permission? Usually it just needs write+execute permissions so the plugin can write the thumbnails properly. – OJ Tibi Mar 19 '12 at 09:29
  • i m in my localhost only., also tried changing the permission.. no thumbnails generated inside uploads/thumb. but the original image is attach is perfectly uploaded into the "uploads" folder. – vijay Mar 19 '12 at 10:10
  • Was this issue ever answered? I am having the same issue with no thumbnails being generated. – lockdown Aug 02 '12 at 16:48