开发者

cakephp media plugin + jQuery Fileuploader plugin

开发者 https://www.devze.com 2023-04-05 16:38 出处:网络
MY CASE: I\'m working on a project on Cakephp, and i\'m using david persson\'s media plugin + jquery Fileuploader plugin following this tutorial. and it works great.

MY CASE:

I'm working on a project on Cakephp, and i'm using david persson's media plugin + jquery Fileuploader plugin following this tutorial. and it works great.

The problem is that my case is a bit more complicated. I want the Attachment model (called Gallery in the tut) to belong to my Posts model and User model, and so I call the fileuploader in my posts' form and in my users' form.

MY PROBLEM

is that no file nor record is created after uploading from my posts' or users' form! any help o开发者_运维问答n how to do that? any website i could take a look at?

I've tried different approaches, but i don't want this question to be neverending...

Thanks in advance.


Impossible to give a proper answer without more information, but for it to work you would need a way of relating media to a post/user. Either as hasMany or HABTM relationship.

e.g a table attachments_posts with id, attachment_id and post_id or user_id

use $this->ModelName->getLastInsertID(); after saving data (and uploading your file to get the ID(s) of the attachment and the user/post record.

You can then insert the id of the post/user and the id of the attachment in to the join table - and link it all together.

0

精彩评论

暂无评论...
验证码 换一张
取 消