I do not know how to debug Uploadify. Everything seems to work, but there is no file uploaded. From the browser ... The page event prints "Done!". Before I used Uploadify, the PHP code worked ... so I don't know where the problem is.
<input id="file_upload" name="file_upload" type="file" rel="<?php echo $group_id; ?>" />
(without <form> )
In Javascript ...
$('#file_upload').uploadify({ 'uploader' : '/media/js/uploadify/uploadify.swf', 'script' : '/bio/community/group_picture/' + $('#file_upload').attr('rel'), 'cancelImg' : '/media/img/bio/_blog_delete.png', 'buttonImg' : '/media/img/bio/browse_files.png', 'wmode' : 'transparent', 'auto' : true, 'width' : 92, 'sizeLimit' : 31457280, 'height' : 26, 'scriptData' : {'session' : session_id}, 'onAllComplete' : function() { location.reload(); } });
In PHP:
Controller:
public function action_group_picture($group_id) { $model_group = Model::factory('Bio_Community_Group'); if (!empty($_FILES)) { $model_group->add_picture($_FILES['file_upload'], $group_id); $this->request->redirect('bio/community/edit_group/' . $group_id); } exit; }
Model:
public function add_picture($image, $group_id) { $filename = $group_id . '.jpg'; $location = 'uploads/bio/community/groups/' . $filename; $image = Image::factory($image['tmp_name']); if ($image->width !== 60 || $image->height !== 60) { $image->crop(60, 60); } $image->save($location); }
I use Kohana, by the way. Any ideas why this doesn't work or how to debug it?
source share