Uploader Plugin officially released!
Tuesday, June 30th 2009, 7:05pm
Topics: Resources, Code, CakePHP
Tags: CakePHP, Uploader, Plugin, Files, Upload
Comments: 9
Permalink -
Tinylink
For the past month I have been talking about CakePHPs lack of a built in uploader component or mechanism, and how I wanted to build one. Well wouldn't it be great if I actually did build it? Oh wait, what is this? I did build one? Yes. Is it released? Yes. May I use it? Of course! The Uploader is primarily used as an all purpose file uploader and was built to not interact with a model/database. Here is a quick rundown of the plugin.
The plugin comes bundled with an uploader component and a validation behavior. The component is used to upload the files to a destination, resize or generate images, validate against mime types, log errors, scan for viruses and more. The behavior is used to add validation rules to a model to check against image uploads.
A big thank you to Mark Story and Matt Curry for beta testing and giving input and ideas.
- Download Uploader v1.3 and view full documentation
The plugin comes bundled with an uploader component and a validation behavior. The component is used to upload the files to a destination, resize or generate images, validate against mime types, log errors, scan for viruses and more. The behavior is used to add validation rules to a model to check against image uploads.
A big thank you to Mark Story and Matt Curry for beta testing and giving input and ideas.
- Download Uploader v1.3 and view full documentation
9 Comments
Jul 6th 2009, 09:56
An example you might want to add is when using your plugin in an existing form saving both normal form data and an uploaded file. The issue I ran into was where the Uploader file validation was occurring after the upload() function instead of before. I fixed this by using validates() in the controller to force validation before both the upload and form save.
Thanks again,
-mike
louiemiranda.com
Jul 14th 2009, 01:07
milesj.me
Jul 14th 2009, 01:30
@Louie - No it is a single file, but you can simply loop on your end or something similar.
Jul 14th 2009, 11:33
i'm trying to use it, it nearly works with my app, but i got one problem
when i'm validating my form, the image si uploaded and thumb created, but validations rules failed & i got this php error :
and the validation error is : Your file type is not allowed
but i'm trying to upload a jpg file.
any idea ? :)
thanks
fishbulb.ca
Jul 16th 2009, 08:36
Thanks again for the great work.
Jul 18th 2009, 08:19
var $actsAs = array(
'Uploader.Validation' => array(
'file' => array(
'dimensions' => array('width' => 100, 'height' => 100),
'extensions' => array('gif', 'jpg', 'png', 'jpeg'),
'optional' => false
)
)
);
boku.co.uk
Jul 18th 2009, 15:12
we're just trying this out for our site.
One thing, in your mime types, you've not got 'image/pjpeg' associated with a jpeg.
This is a mime type IE can send - and so it doesn't set the group to be image when using it; so messed up a bit.
I agree with the comment about writing in the tutorial that you have to call Model->validates, as before I used that I was under the impression that there was a way to pass a reference of the Model to the component and the component would call validates against that model reference.
but it's looking good otherwise,
Cheers
Dec 27th 2009, 11:24
Warning (2): mkdir() [function.mkdir]: No such file or directory [CORE\cake\libs\folder.php, line 466]
Dec 27th 2009, 14:22
Apr 15th 2010, 11:39
windows this warning is showing:
Warning (2): mkdir() [function.mkdir]: No such file or directory [CORE\cake\libs\folder.php, line 466]
Please help me
Regards
Amit Pandya
manasgajare.com
Jan 8th 2011, 10:53
Oct 28th 2011, 15:12
I am trying to use the Uploader plugin with CakePHP v2.0. I moved 'Uploader' folder under /app/Config/Plugin
Added the following line in app/Config/bootstrap.php
CakePlugin::loadAll();
and then used the public $components = array('Session', 'Cookie','Uploader.Uploader'); in my controller. As soon as I load the relevant function from the controller. I get a blank page. Am i missing something?
Any advice/ help is deeply appreciated.
Thanks