1

Just like the title says, I'd like to use Cake's Active Record DAL within a vendor class. I'm currently using the Blueimp jQuery File Upload plugin, and would like to extend it's upload handler so I can save file info to the db using Cake.

I'm loading the upload handler via

App::import('Vendor', 'jQueryFileUpload/UploadHandler');

What i'd like to do is load CustomUploadHandler that extends UploadHandler

App::import('Vendor', 'jQueryFileUpload/CustomUploadHandler');

And instead of creating a new connection and using SQL, I'd like to use methods like save() and saveAll() in CustomUploadHandler. Any suggestions?

dcd0181
  • 1,493
  • 4
  • 29
  • 52

1 Answers1

1

First, don't store files in the DB. Why? See this question.

I think your approach is wrong. That jquery script will just send post data to a server and expects a json response. There is no need to pull the CakePHP ORM out and put it in a random file and detach the file uploading completely from your application. Specially if you want to use auth you would have to reimplement your auth system in the vendor code.

Instead implement the upload handling inside of your CakePHP app. We've recently done this with jquery file upload and this plugin. We haven't used the example code (that's what it is IMHO) that comes with the jquery plugin at all.

Community
  • 1
  • 1
floriank
  • 25,546
  • 9
  • 42
  • 66