Decoda

Decoda is a lightweight lexical string parser for BBCode styled markup.

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
Related Entries:

9 Comments

10 / 2 = ?
Allowed: [code] [b] [i] [u]
  • Mike
    Jul 6th 2009, 09:56
    1 Thanks a ton for creating this Miles. It's already saved me tons work when dealing with uploads and image resizing.

    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
  • Louie Miranda
    louiemiranda.com
    Jul 14th 2009, 01:07
    2 Hi Miles, I was wondering if multiple uploading is possible on your component?
  • Miles Johnson
    milesj.me
    Jul 14th 2009, 01:30
    3 @Mike - Well of course you would need to call validates(), the validation is based on the model and needs to be called.

    @Louie - No it is a single file, but you can simply loop on your end or something similar.
  • mevimu
    Jul 14th 2009, 11:33
    4 Hello, thanks for your great work !

    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 :
    Warning (2): getimagesize(/) [function.getimagesize]: failed to open stream: No such file or directory [APP\plugins\uploader\models\behaviors\validation.php, line 117]


    and the validation error is : Your file type is not allowed

    but i'm trying to upload a jpg file.
    any idea ? :)
    thanks
  • Phil
    fishbulb.ca
    Jul 16th 2009, 08:36
    5 Terrific stuff Miles. I will definitely be using this for an upcoming project. Like Louie, I too would love to be able to upload multiple files. Unfortunately I don't really understand how to go about this based on your comment. Would it be too much to ask if you would include an example in the docs?

    Thanks again for the great work.
  • ekenfire
    Jul 18th 2009, 08:19
    6 Hi,I've got a problem.That's validation in Model doesn't work.I don't know why.I have added the codes into the Model,but it didn't work when i test.I am going crazy!


    var $actsAs = array(
    'Uploader.Validation' => array(
    'file' => array(
    'dimensions' => array('width' => 100, 'height' => 100),
    'extensions' => array('gif', 'jpg', 'png', 'jpeg'),
    'optional' => false
    )
    )
    );


  • Henry
    boku.co.uk
    Jul 18th 2009, 15:12
    7 Heya,

    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
  • Drum
    Dec 27th 2009, 11:24
    8 This i great file upload plugin. On linux is working very well, but on windows this warning is showing:
    Warning (2): mkdir() [function.mkdir]: No such file or directory [CORE\cake\libs\folder.php, line 466]
  • Drum
    Dec 27th 2009, 14:22
    9 Sorry, just ignore my comment...
  • Amit
    Apr 15th 2010, 11:39
    10 My Server running on Linux and I am using my window browser, I have permission 0777 even those I am receiving following error

    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
  • Manas Gajare
    manasgajare.com
    Jan 8th 2011, 10:53
    11 Hey I used the uploader script. Found tremendously helpful. Kudos!
  • Anand
    Oct 28th 2011, 15:12
    12 Hello,

    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