code tunes

Web applications, software engineering, Ruby on Rails, Cake PHP, JavaScript, etc.

Archive for the ‘UploadPack’ tag

UploadPack - easy and flexible way to upload files with CakePHP

with 3 comments

I have seen and worked with many scripts and plugins (not only written in PHP) that tries to deal with file-upload functionality on server side, thanks to this I think I have some view on how good file-upload plugin should work. The thing was to put it in CakePHP clothes and code it.

Here are the requirements I set:

  • save procedure of record with attached file should be no different to usual record
  • it should be possible to do some additional processing of uploaded file at the time of saving it (for example thumbnail generation)
  • easy access to uploded file, it’s URL and alternatives (different thumnails) from view level
  • everything should require no or minimum configuration to work, but still remain flexible if the whole application needs it
  • natural integration with CakePHP framework

Here’s the effect of some planning and coding - UploadPack. Right now it contains:

  • UploadBehavior - deals with saving files to disk and post-save processing
  • UploadHelper - provides nice access to files (URLs, thumbnails) from view level

Everything works quite gracefully, I think. You only need to add one field to model’s database table (which will hold file name) and attach behavior to model. The rest is done automatically. Everything is documented on repository’s page.

It’s still an early version - 0.1, but there is much it can do right now. The work is underway to provide new features. Take a look at it.

If you have any views or ideas, please leave a comment. I’d appreciate it.

Written by Michał Szajbe

November 4th, 2008 at 9:13 pm