Question

I'm using CakePHP 2.3.6 and just added Miles Johnson's image uploader. Everything seems to work when I use my View to upload a photo I get a success return. A file gets created with the right name, so formatName function seams to work. But the size of the created file is always only 56bytes. No matter how big the originally uploaded file was.

I have the strong feeling that there is something wrong with user rights or with configuration of apache server that it maybe does't alow upload.

Does anybody know what could let me create a file but not put content into this file? On the Uploader Howto there is nothing said about any changes I would have to do on apache or php configuration.

View:

<?php
    echo $this->Form->create('Site');
    echo $this->Form->input('startpageImage', array('type' => 'file'));
    echo $this->Form->end('Submit');
?>

Model:

public $actsAs = array(
    'Uploader.Attachment' => array(
        'startpageImage' => array(
            'tempDir' => TMP,
            'finalPath' => '/img/uploads/',
            'nameCallback' => 'formatName',         
        )
    )
);
public function formatName($name, $file) {
    return sprintf('%s-%s', $this->field('id'), $name);
}
Was it helpful?

Solution

I wrote a email to Miles Jones and he found the mistake immediately:

View:

<?php
echo $this->Form->create('Site', array('type' => 'file'));
echo $this->Form->input('startpageImage', array('type' => 'file'));
echo $this->Form->end('Submit');
?>

I forgot the

, array('type' => 'file')

in the first line of Form. No black magic, no rocket science... :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top