{"id":18247042,"url":"https://github.com/thyseus/yii2-files","last_synced_at":"2025-10-10T19:38:58.155Z","repository":{"id":141909613,"uuid":"75638189","full_name":"thyseus/yii2-files","owner":"thyseus","description":"A General File Upload Manager for the Yii 2 framework. Files can be uploaded and linked to an ActiveRecord Model. Contains only one table 'files' where everything is stored. The files are uploaded into an protected folder by default.","archived":false,"fork":false,"pushed_at":"2018-06-06T08:23:41.000Z","size":86,"stargazers_count":4,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T14:38:14.166Z","etag":null,"topics":["files","yii2","yii2-extension","yii2-files"],"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/thyseus.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-05T15:27:48.000Z","updated_at":"2019-06-24T16:18:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"f3e007b9-9a17-4283-995e-db12207bb7e3","html_url":"https://github.com/thyseus/yii2-files","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/thyseus/yii2-files","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thyseus%2Fyii2-files","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thyseus%2Fyii2-files/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thyseus%2Fyii2-files/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thyseus%2Fyii2-files/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thyseus","download_url":"https://codeload.github.com/thyseus/yii2-files/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thyseus%2Fyii2-files/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005034,"owners_count":26083827,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["files","yii2","yii2-extension","yii2-files"],"created_at":"2024-11-05T09:28:45.431Z","updated_at":"2025-10-10T19:38:58.104Z","avatar_url":"https://github.com/thyseus.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ATTENTION:\n\ngithub has been bought by Microsoft. This repository is orphaned and has been moved to:\n\nhttps://gitlab.com/thyseus/yii2-files\n\nThanks a lot for your understanding and blame Microsoft.\n\n# Yii2-files\n\nA General File Upload Manager for the Yii 2 framework.\n\nFiles can be uploaded and linked to any ActiveRecord Model. Since version 0.3.0 the user\ncan upload files without the need to link to an Model.\n \nIt uses the kartik-v/yii2-widget-fileinput widget (https://github.com/kartik-v/yii2-widget-fileinput).\n\nIt contains only one database table 'files' where everything is stored.\n\nA simple Access Control is provided. All Files are uploaded into an protected folder by default and can\nbe set to public for everyone or for specific users by the uploader.\n\nThe upload endpoint has been designed with this document in mind:\nhttp://webtips.krajee.com/ajax-based-file-uploads-using-fileinput-plugin/\n\nIn case images are uploaded, a simple image cropper is provided.\n\nTranslations are available to german and english currently.\n\n## Installation\n\n```bash\n$ cd /your/project/root\n$ composer require thyseus/yii2-files\n$ php yii migrate/up --migrationPath=@vendor/thyseus/yii2-files/migrations\n$ mkdir uploads/\n$ echo '.uploads/' \u003e\u003e .gitignore\n```\n\n## Security\n\nNote that by default all users that apply to Yii::$app-\u003euser-\u003ecan('admin') are able to see, download \nand remove all files that are available in the database. Every other user can only access his own \nuploaded files and files that he has shared with other users. Guests can only see public files.\n\nSince 0.3.0 users can share his files with users he chooses to. In order to make these feature to\nwork, you need to provide an app\\models\\User Active Record model with at least the attributes \n'id' and 'username'.\n\n## Important Update Notice:\n\nSince 0.4.0 (2017-12-18) yii2-files does automatically save a md5 checksum of each file that is being uploaded.\nThis checksum is being checked when downloading the file.\nEnsure that your migrations have been executed so that the column 'checksum' exists.\nIn order to update all already uploaded files with the correct checksum, please run the following command in your\nyii2-shell:\n\n```php\nforeach(thyseus\\files\\models\\File::find()-\u003eall() as $file) {\n    if (!$file-\u003echecksum) {\n        $file-\u003eupdateAttributes(['checksum' =\u003e md5(@file_get_contents($file-\u003efilename_path))]);\n    }\n}\n```\n\n## Configuration\n\nAdd following lines to your main configuration file:\n\n```php\n'modules' =\u003e [\n    'files' =\u003e [\n        'class' =\u003e 'thyseus\\files\\FileWebModule',\n    ],\n],\n```\n\n## Integration in your application:\n\nAttach the hasFilesBehavior onto every ActiveRecord model that you want to attach files to:\n\n```php\nuse \\thyseus\\files\\behaviors\\HasFilesBehavior;\n\n    public function behaviors()\n    {\n        return [\n                HasFilesBehavior::class,\n                ];\n    }\n```\n\nYou can access every uploaded file that is attached to the Active Record model depending on the current\nlogged in user via:\n\n```php\n$model-\u003efiles;\n```\n\nYou can render an upload widget that attaches every uploaded file automatically to the model by using:\n\n```php\nuse yii\\helpers\\Url;\n\necho $this-\u003erender('@vendor/thyseus/yii2-files/views/file/_upload', [\n    'model' =\u003e $model,\n    'options' =\u003e ['multiple' =\u003e true], // optional\n    'target_url' =\u003e Url::to(['agency/view', 'id' =\u003e $model-\u003eslug]), // optional\n    'uploadExtraData' =\u003e ['public' =\u003e true] // uploaded files are automatically public (default is: protected). optional.\n]);\n```\n\nUse\n```php\nuse thyseus\\files\\models\\File;\n\n$model = File::findOne(57);\necho File::downloadLink();\n```\n\nto display a \"Download file\" button in the view file.\n\n## Events\n\nYou can attach events to most of the actions, for example to send a notification once a user gets\naccess to a shared file, like this:\n\n```php\nuse yii\\base\\Event;\nuse thyseus\\files\\controllers\\FileController;\n\nEvent::on(FileController::class, FileController::EVENT_AFTER_SHARE_WITH_USER, function ($event) {\n    $username = $event-\u003esender-\u003eactionParams['username'];\n    \n    Message::sendNotification($username); // \u003c-- you need to implement this\n});\n```\n\n## Routes\n\nYou can use the following routes to access the files module:\n\n* list all files of the current logged in user: https://your-domain/files/files/index\n* view: https://your-domain/files/files/view?id=\u003cid\u003e\n* update: 'files/update/\u003cid\u003e' =\u003e 'files/files/update',\n* delete: 'files/delete/\u003cid\u003e' =\u003e 'files/files/delete',\n* view: 'files/\u003cid\u003e' =\u003e 'files/files/view',\n\n## License\n\nYii2-files is released under the GPLv3 License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthyseus%2Fyii2-files","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthyseus%2Fyii2-files","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthyseus%2Fyii2-files/lists"}