{"id":13824990,"url":"https://github.com/fusic/filebinder","last_synced_at":"2025-05-07T01:49:50.828Z","repository":{"id":960627,"uuid":"748651","full_name":"fusic/filebinder","owner":"fusic","description":"Filebinder: Simple file attachment plugin for CakePHP","archived":false,"fork":false,"pushed_at":"2019-06-20T09:52:18.000Z","size":305,"stargazers_count":69,"open_issues_count":1,"forks_count":16,"subscribers_count":22,"default_branch":"2.0","last_synced_at":"2025-03-31T05:11:16.247Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fusic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-06-30T08:34:05.000Z","updated_at":"2020-06-11T12:33:27.000Z","dependencies_parsed_at":"2022-08-16T11:35:26.840Z","dependency_job_id":null,"html_url":"https://github.com/fusic/filebinder","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fusic%2Ffilebinder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fusic%2Ffilebinder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fusic%2Ffilebinder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fusic%2Ffilebinder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fusic","download_url":"https://codeload.github.com/fusic/filebinder/tar.gz/refs/heads/2.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252798781,"owners_count":21805880,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T09:01:13.138Z","updated_at":"2025-05-07T01:49:50.804Z","avatar_url":"https://github.com/fusic.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Filebinder: Simple file attachment plugin for CakePHP\n\n![Image](https://raw.github.com/fusic/filebinder/2.0/Document/filebinder.png)\n\n[![Build Status](https://travis-ci.org/fusic/filebinder.png?branch=2.0)](https://travis-ci.org/fusic/filebinder)\n\n## Feature\n\n- Simple settings\n- Compatible with Transition Component\n- Multi attachement\n- Selectalble file store method (DB storage or not)\n\n## Requirements\n\n- PHP \u003e= 5.2.6\n- CakePHP \u003e= 2.0\n\n## Installation\n\nPut 'Filebinder' directory on app/plugins in your CakePHP application.\nThen, add the following code in bootstrap.php\n\n    \u003c?php\n        CakePlugin::load('Filebinder');\n\n## Filebinder outline image\n\nFilebinder manage 'virtual table' and entity.\n\n### 'Simple attachment' model image\n\n![Image](https://raw.github.com/fusic/filebinder/2.0/Document/filebinder_image.png)\n\n### 'Multi fields' model image\n\n![Image](https://raw.github.com/fusic/filebinder/2.0/Document/filebinder_multi_fields.png)\n\n### 'Multi models' model image\n\n![Image](https://raw.github.com/fusic/filebinder/2.0/Document/filebinder_multi_models.png)\n\n### Entity file path image\n\n![Image](https://raw.github.com/fusic/filebinder/2.0/Document/filebinder_filepath.png)\n\n## Usage\n\nExample of how to add image file with confirm page.\n\n    \u003c?php\n    class Post extends AppModel {\n       public $name = 'Post';\n       public $actsAs = array('Filebinder.Bindable');\n       public $displayField = 'title';\n          \n       public $bindFields = array(array('field' =\u003e 'image',\n                                     'tmpPath' =\u003e '/var/www/html/myapp/app/webroot/files/cache/',\n                                     'filePath' =\u003e '/var/www/html/myapp/app/webroot/files/',\n                                     ));\n          \n       public $validate = array('title' =\u003e array('notempty'),\n                             'image' =\u003e array('allowExtention' =\u003e array('rule' =\u003e array('checkExtension', array('jpg')),\n                                                                       'allowEmpty' =\u003e true),\n                                              'illegalCode' =\u003e array('rule' =\u003e array('funcCheckFile', 'checkIllegalCode'),\n                                                                    'allowEmpty' =\u003e true))\n                             );\n    \n       /**\n        * checkIllegalCode\n        * check include illegal code\n        *\n        * @param $filePath\n        * @return\n        */\n       public function checkIllegalCode($filePath){\n           $fp = fopen($filePath, \"r\");\n           $ofile = fread($fp, filesize($filePath));\n           fclose($fp);\n    \n           if (preg_match('/\u003c\\\\?php./i', $ofile)) {\n               return false;\n           }\n           return true;\n       }\n     }\n\nCreate attachment table.\n\n    CREATE TABLE `attachments` (\n     `id` int(11) NOT NULL AUTO_INCREMENT,\n     `model` text NOT NULL,\n     `model_id` int(11) NOT NULL,\n     `field_name` text NOT NULL,\n     `file_name` text NOT NULL,\n     `file_content_type` text NOT NULL,\n     `file_size` int(11) NOT NULL,\n     `file_object` longtext,\n     `created` datetime DEFAULT NULL,\n     `modified` datetime DEFAULT NULL,\n     PRIMARY KEY (`id`)\n    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n    \u003c?php\n    class PostsController extends AppController {\n     \n        public $name = 'Posts';\n        public $components = array('Session', 'Filebinder.Ring', 'Transition');\n     \n        /**\n         * add\n         */\n        public function add() {\n            $this-\u003eRing-\u003ebindUp();\n            $this-\u003eTransition-\u003echeckData('add_confirm');\n            $this-\u003eTransition-\u003eclearData();\n        }\n     \n        /**\n         * add_confirm\n         */\n        public function add_confirm(){\n            $this-\u003eTransition-\u003echeckPrev(array('add'));\n     \n            $this-\u003eTransition-\u003eautomate('add_success',\n                                        false,\n                                        'add');\n            $mergedData = $this-\u003eTransition-\u003emergedData();\n            $this-\u003eset('mergedData', $mergedData);\n        }\n     \n        /**\n         * add_success\n         */\n        public function add_success(){\n            $this-\u003eTransition-\u003echeckPrev(array('add',\n                                               'add_confirm'));\n            $mergedData = $this-\u003eTransition-\u003emergedData();\n     \n            if ($this-\u003ePost-\u003esave($mergedData)) {\n                $this-\u003eTransition-\u003eclearData();\n                $this-\u003eSession-\u003esetFlash(sprintf(__('The %s has been saved', true), 'post'));\n                $this-\u003eredirect(array('action' =\u003e 'index'));\n            } else {\n                $this-\u003eSession-\u003esetFlash(sprintf(__('The %s could not be saved. Please, try again.', true), 'post'));\n                $this-\u003eredirect(array('action' =\u003e 'add'));\n            }\n        }\n    }\n\n add.ctp\n\n    \u003cdiv class=\"posts form\"\u003e\n      \u003ch2\u003e\u003c?php printf(__('Add %s', true), __('Post', true)); ?\u003e\u003c/h2\u003e\n      \u003c?php echo $this-\u003eForm-\u003ecreate('Post', array('action' =\u003e 'add', 'type' =\u003e 'file'));?\u003e\n      \u003c?php echo $this-\u003eForm-\u003einput('title', array('type' =\u003e 'text'));?\u003e\n      \u003c?php echo $this-\u003eForm-\u003einput('body');?\u003e\n      \u003c?php echo $this-\u003eForm-\u003einput('image', array('type' =\u003e 'file'));?\u003e\n      \u003c?php echo $this-\u003eForm-\u003esubmit(__('Submit', true));?\u003e\n      \u003c?php echo $this-\u003eForm-\u003eend();?\u003e\n    \u003c/div\u003e\n\n add_confirm.ctp\n\n    \u003cdiv class=\"posts form\"\u003e\n      \u003ch2\u003e\u003c?php printf(__('Confirm %s', true), __('Post', true)); ?\u003e\u003c/h2\u003e\n      \n      \u003c?php echo h($mergedData['Post']['title']);?\u003e\n      \u003c?php echo h($mergedData['Post']['body']);?\u003e\n      \u003c?php echo $this-\u003eLabel-\u003eimage($mergedData['Post']['image']);?\u003e \n      \u003c?php echo $this-\u003eForm-\u003ecreate('Post', array('action' =\u003e 'add_confirm'));?\u003e   \n      \u003c?php echo $this-\u003eForm-\u003einput('dummy', array('type' =\u003e 'hidden'));?\u003e\n      \u003c?php echo $this-\u003eForm-\u003esubmit(__('Submit', true));?\u003e\n      \u003c?php echo $this-\u003eForm-\u003eend();?\u003e\n    \u003c/div\u003e\n\n\n## Amazon S3 combination\n\n### Requirements\n\n- aws-sdk 1.5.*\n\n### Setting\n\n\n    \u003c?php\n    Configure::write('Filebinder.S3.key', '************************');\n    Configure::write('Filebinder.S3.secret', '********************************************');\n    Configure::write('Filebinder.S3.region', 'ap-northeast-1');\n\n\n    \u003c?php\n    class Post extends AppModel {\n        public $name = 'Post';\n        public $actsAs = array('Filebinder.Bindable' =\u003e array('storage' =\u003e array('Db', 'S3'))); // using Database and Amazon S3 for object storage\n        public $displayField = 'title';\n           \n        public $bindFields = array(array(\n                                  'field' =\u003e 'image',\n                                  'tmpPath' =\u003e '/var/www/html/myapp/app/webroot/files/cache/',\n                                  'filePath' =\u003e '/var/www/html/myapp/app/webroot/files/',\n                                  'bucket' =\u003e 'aws.foobacket', // bucket name,\n                                  // 'acl' =\u003e AmazonS3::ACL_PUBLIC, // S3 ACL\n                                  ));\n    }\n\n\n## License\n\nThe MIT License\n\nCopyright (c) 2010-2011 Fusic Co., Ltd. (http://fusic.co.jp)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffusic%2Ffilebinder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffusic%2Ffilebinder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffusic%2Ffilebinder/lists"}