milesj / uploader

[Deprecated] A CakePHP plugin for file uploading and validating.
MIT License
193 stars 73 forks source link

fails on entering filename into db column #116

Closed deanezra closed 11 years ago

deanezra commented 11 years ago

Please forgive me if I am missing a step, but I have followed your steps shown here:

http://milesj.me/code/cakephp/uploader

I have a column called csvfilename of type text in mysql fleets table which is added as a behaviour in my Fleets model:

public $actsAs = array( 'Uploader.Attachment' => array( 'csvfilename' => array( 'nameCallback' => '', 'append' => '', 'prepend' => '', 'tempDir' => TMP, 'uploadDir' => '', 'finalPath' => '', 'dbColumn' => '', 'metaColumns' => array(), 'defaultPath' => '', 'overwrite' => false, 'stopSave' => true, 'allowEmpty' => true, 'transforms' => array(), 'transport' => array() ) ) );

However I am getting the following error from cakephp upon pressing the submit on the form after selecting a file to upload:

Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Array' in 'field list'

SQL Query: INSERT INTO evemineit.fleets (date, csvfilename, modified, created) VALUES ('2013-05-28 21:44:00', Array, '2013-05-28 21:44:47', '2013-05-28 21:44:47')

Shouldn't the 'array' value be the filename of the upload?

milesj commented 11 years ago

You don't need to define all those setting since default are provided.

What version of Cake and the Uploader are you using? Does your form and input have type = file?

deanezra commented 11 years ago

Version of uploader is: 4.1.0 (installed via composer) Version of cakephp is: 2.3.2

My view (/view/Fleets/add.ctp) has the following form with csvfilename input which links to the upload behaviour:

Add a new mining fleet into the system

<?php echo $this->Form->create('Fleet', array('type' => 'file')); // Other inputs echo $this->Form->input('date');

echo $this->Form->input('csvfilename', array('type' => 'file')); echo $this->Form->end('Submit'); ?>

deanezra commented 11 years ago

Aha, if I reduce the behaviour definition to the following, it works:

public $actsAs = array( 'Uploader.Attachment' => array( 'csvfilename' => array( 'overwrite' => false, 'stopSave' => true, 'allowEmpty' => false ) ) );

Not sure why, but I am happy! Thanks for the help.

milesj commented 11 years ago

Yeah, that's weird that it works when you remove some settings. I'll do some testing and figure it out.

milesj commented 11 years ago

Figured it out was the empty dbColumn field.

deanezra commented 11 years ago

Thanks for digging into this more. Really impressed with your plugin. very useful

On 29 May 2013 21:11, Miles Johnson notifications@github.com wrote:

Figured it out was the empty dbColumn field.

— Reply to this email directly or view it on GitHubhttps://github.com/milesj/Uploader/issues/116#issuecomment-18642721 .

Dean Ezra Email: dean@deanezra.com