I'm using meioupload and everything works well till I try to make thumbnails. Then I can see only kind of phpThumb error message which says

"C:/wamp/cakephp/vendors/phpTmub/img/uploads/product/filename/image.png" does not exist

I'm new with cakePHP so I never faced this problem before. Does anyone know what should I do?

here is my model code:

var $actsAs = array(
    'MeioUpload' => array(
        'filename' => array(
            'create_directory' => true,
            'allowed_mime' => array('image/jpeg', 'image/pjpeg', 'image/png'),
            'allowed_ext' => array('.jpg', '.jpeg', '.png'),
            'zoomCrop' => true,
            'thumbsizes' => array(
                'normal' => array('width' => 400, 'height' => 300),
                'small' => array('width' => 80, 'height' => 80,'maxDimension' => '', 'thumbnailQuality' => 100, 'zoomCrop' => true),
                ),
            'default' => 'default.jpg'
            ) 
        ));

UPDATE:

I found special phpThumb for cakePHP 2.0 so the Path changed into this:

"C:/wamp/cakephp/img/uploads/product/filename/image.png"

and if I open default image in my browser th path is like:

localhost:8080/cakephp/img/uploads/product/filename/image.png

Thanks

有帮助吗?

解决方案

I solved the problem, maybe not very elegant, but it works! For the first time, as I said, I downloaded special version of phpThumb for cakePHP.

Here is link: https://github.com/simkimsia/phpThumb-for-cakephp-2.0

After there was my problem with the path because my images was in folder: C:\wamp\www\cakephp\app\webroot\img\uploads\product\filename\image.png

So I had to find this part of code(begins on line 1078):

if ($this->useCake) {
                if ($this->config_document_root != null) {
                    $AbsoluteFilename = $this->config_document_root.DIRECTORY_SEPARATOR.$filename;
                } else {
                    $AbsoluteFilename = WWW_ROOT.DIRECTORY_SEPARATOR.$filename;
                }
            }

And edit a the path to fit into my folder:

$AbsoluteFilename = $this->config_document_root.DIRECTORY_SEPARATOR.'cakephp'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'webroot'.DIRECTORY_SEPARATOR.$filename;

$AbsoluteFilename = WWW_ROOT.DIRECTORY_SEPARATOR.'cakephp'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'webroot'.DIRECTORY_SEPARATOR.$filename;

and now its working perfectly...

其他提示

after try many things.. and finally read the answer of Jan Omacka, i only have to edit phpthumb.class.php, line 223 in the constructor function phpThumb()

First

// public: constructor
function phpThumb() {
.....
//comment line 
//$this->config_document_root = (!empty($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT']   : $this->config_document_root);
.....
}


//and put the constant CakePHP Var WWW_ROOT (Full path to the webroot.) 
$this->config_document_root = WWW_ROOT;
//and if this don't work.. put your real path in linux, or windows
//$this->config_document_root = '/srv/www/htdocs/sic/app/webroot/';

In my case inside webroot, have a folder with estructure 'Usuarios/ID_Prestamo/IDUsuario/', all works great uploading the picture but thumbs not.. so after download the last version of phpThumb, i saw that show an error of File does not exist (URL misformat, for original JPG File), after that download the special versión for CakePhp and change the lines as mentioned.. and all works... I use OpenSuse Linux, Apache2, with Cake 2.4.2

Notes: I verified that if not have zoomCrop it not works, this is my structure

 'dir' => 'galeria/', //main folder webroot/galeria/ 
                'createDirectory' => true,
                'maxSize'=>'5 Mb',
                'allowedExt' => array('.jpg','.jpeg','.png'),
                'zoomCrop' => true,
                'thumbsizes' => array(
                    'small'  => array('width'=>165, 'height'=>115),
                    'medium' => array('width'=>800, 'height'=>600)
                ),
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top