Sunday, March 3, 2013

Question on using Miles Uploader Plugin

I'm running into using Miles Uploader Plugin, found here. The issue is, the photos are being created, but they're invalid, in all cases, they're around 300 - 400 bytes. They do have the original file name, but that's about it.

Using latest version of Cakephp
Using latest version of Uploader, using composer to gather all required lib's.

Now, they way I'm using it is:

Controllers:

Stores
Images

//Add method in the Stores Controller
public function add() {
if ($this->request->is('post')) {
$this->Store->create();
if ($this->Store->saveAll($this->request->data, array('deep' => true))) {
$this->Session->setFlash(__('The store has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The store could not be saved. Please, try again.'));
}
}
$users = $this->Store->User->find('list');
$types = $this->Store->Type->find('list');
$this->set(compact('users', 'types'));
}

Here's my add.ctp, just a sample of what I changed:

<div class="stores form">
<?php echo $this->Form->create('Store'); ?>
<fieldset>
<legend><?php echo __('Add Store'); ?></legend>
<?php
echo $this->Form->input('name');
echo $this->Form->input('user_id');
echo $this->Form->input('type_id');
echo $this->Form->input('details');
echo $this->Form->input('phone');
echo $this->Form->input('address');
echo $this->Form->input('city');
echo $this->Form->input('state');
echo $this->Form->input('zip');
echo $this->Form->input('url');
echo $this->Form->input('is_published');
echo $this->Form->input('Image.0.name', array('type' => 'file'));
//echo $this->Form->hidden('Image.0.is_cover', array('value' => 1));
?>
</fieldset>
<?php echo $this->Form->end(__('Submit')); ?>
</div>

Now, in the Images Model, I have the following:

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

Here's the structure for the Images table:

CREATE TABLE IF NOT EXISTS `images` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `store_id` int(11) DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  `is_cover` tinyint(1) DEFAULT '0',
  `path` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

So, part of this is working correctly, I'm just not sure why they actual file isn't being uploaded. When I use Charles, I see the post for when I submit a Store, but it doesn't look like the photo is actually being uploaded at all.

Any help would be awesome!

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: