{"id":13623946,"url":"https://github.com/brandonsavage/Upload","last_synced_at":"2025-04-15T20:32:52.640Z","repository":{"id":4605948,"uuid":"5749199","full_name":"brandonsavage/Upload","owner":"brandonsavage","description":"File uploads with validation and storage strategies","archived":true,"fork":false,"pushed_at":"2023-11-12T03:17:29.000Z","size":89,"stargazers_count":1667,"open_issues_count":39,"forks_count":314,"subscribers_count":85,"default_branch":"master","last_synced_at":"2024-10-30T04:54:26.577Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brandonsavage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2012-09-10T12:34:41.000Z","updated_at":"2024-10-18T09:39:21.000Z","dependencies_parsed_at":"2024-05-05T08:47:02.372Z","dependency_job_id":null,"html_url":"https://github.com/brandonsavage/Upload","commit_stats":{"total_commits":56,"total_committers":21,"mean_commits":"2.6666666666666665","dds":0.6607142857142857,"last_synced_commit":"b32c8ae4e0e6e050696db9166a7dd57a186ef09a"},"previous_names":["codeguy/upload"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandonsavage%2FUpload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandonsavage%2FUpload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandonsavage%2FUpload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandonsavage%2FUpload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brandonsavage","download_url":"https://codeload.github.com/brandonsavage/Upload/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223684882,"owners_count":17185734,"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-01T21:01:37.210Z","updated_at":"2024-11-08T12:30:35.272Z","avatar_url":"https://github.com/brandonsavage.png","language":"PHP","funding_links":[],"categories":["Table of Contents","目录","PHP","过滤和验证 Filtering and Validation"],"sub_categories":["Filtering, Sanitizing and Validation","Filtering and Validation","过滤和验证 Filtering and Validation","Globalization"],"readme":"# Upload\n\n[![Build Status](https://img.shields.io/travis/brandonsavage/Upload.svg?style=flat-square)](https://travis-ci.org/brandonsavage/Upload)\n[![Latest Version](https://img.shields.io/github/release/brandonsavage/Upload.svg?style=flat-square)](https://github.com/brandonsavage/Upload/releases)\n[![Total Downloads](https://img.shields.io/packagist/dt/codeguy/upload.svg?style=flat-square)](https://packagist.org/packages/codeguy/upload)\n\nThis component simplifies file validation and uploading.\n\n## Usage\n\nAssume a file is uploaded with this HTML form:\n\n```html\n\u003cform method=\"POST\" enctype=\"multipart/form-data\"\u003e\n    \u003cinput type=\"file\" name=\"foo\" value=\"\"/\u003e\n    \u003cinput type=\"submit\" value=\"Upload File\"/\u003e\n\u003c/form\u003e\n```\n\nWhen the HTML form is submitted, the server-side PHP code can validate and upload the file like this:\n\n```php\n\u003c?php\n$storage = new \\Upload\\Storage\\FileSystem('/path/to/directory');\n$file = new \\Upload\\File('foo', $storage);\n\n// Optionally you can rename the file on upload\n$new_filename = uniqid();\n$file-\u003esetName($new_filename);\n\n// Validate file upload\n// MimeType List =\u003e http://www.iana.org/assignments/media-types/media-types.xhtml\n$file-\u003eaddValidations(array(\n    // Ensure file is of type \"image/png\"\n    new \\Upload\\Validation\\Mimetype('image/png'),\n\n    //You can also add multi mimetype validation\n    //new \\Upload\\Validation\\Mimetype(array('image/png', 'image/gif'))\n\n    // Ensure file is no larger than 5M (use \"B\", \"K\", M\", or \"G\")\n    new \\Upload\\Validation\\Size('5M')\n));\n\n// Access data about the file that has been uploaded\n$data = array(\n    'name'       =\u003e $file-\u003egetNameWithExtension(),\n    'extension'  =\u003e $file-\u003egetExtension(),\n    'mime'       =\u003e $file-\u003egetMimetype(),\n    'size'       =\u003e $file-\u003egetSize(),\n    'md5'        =\u003e $file-\u003egetMd5(),\n    'dimensions' =\u003e $file-\u003egetDimensions()\n);\n\n// Try to upload file\ntry {\n    // Success!\n    $file-\u003eupload();\n} catch (\\Exception $e) {\n    // Fail!\n    $errors = $file-\u003egetErrors();\n}\n```\n\n## How to Install\n\nInstall composer in your project:\n\n```\ncurl -s https://getcomposer.org/installer | php\n```\n\nRequire the package with composer:\n\n```\nphp composer.phar require codeguy/upload\n```\n\n## Author\n\n[Josh Lockhart](https://github.com/codeguy)\n\n## License\n\nMIT Public License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandonsavage%2FUpload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrandonsavage%2FUpload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandonsavage%2FUpload/lists"}