{"id":16618510,"url":"https://github.com/dimo414/imgupload","last_synced_at":"2025-03-11T05:45:42.787Z","repository":{"id":155531037,"uuid":"234492082","full_name":"dimo414/imgupload","owner":"dimo414","description":"Utility to support user-uploaded images to a PHP server","archived":false,"fork":false,"pushed_at":"2020-01-17T07:10:05.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-17T20:46:25.947Z","etag":null,"topics":["image-processing","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dimo414.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":"2020-01-17T07:09:45.000Z","updated_at":"2021-01-25T08:38:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"92ab7e5d-0310-4e8d-82e5-7a8675cdd89f","html_url":"https://github.com/dimo414/imgupload","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimo414%2Fimgupload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimo414%2Fimgupload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimo414%2Fimgupload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimo414%2Fimgupload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimo414","download_url":"https://codeload.github.com/dimo414/imgupload/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242980782,"owners_count":20216285,"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":["image-processing","php"],"created_at":"2024-10-12T02:20:26.079Z","updated_at":"2025-03-11T05:45:42.762Z","avatar_url":"https://github.com/dimo414.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Secure Image Uploader\r\n\r\nEasy, secure image uploader for handling form submissions with PHP\r\n\r\n## Usage\r\n\r\nThe `ImgUploader` class is very self contained, all you really need to know for basic usage is as follows:\r\n\r\n* Constructor\r\n  \r\n    Pass to the constructor the information of one item in the `$_FILES` array - for instance\r\n    `$_FILES['uploadedImage']` if your form used the name `uploadedImage`.\r\n  \r\n* `upload_unscaled()`\r\n\r\n    `upload_unscaled()` takes two parameters, a directory (or series of directories) and a filename *without* the extension.\r\n    the directories should be from the web root (though you can of course use ../ to navigate above that).\r\n    the filename will be appended with the appropriate extension automatically.\r\n\r\n* `upload()`\r\n\r\n    `upload()` takes two additional parameters to `upload_unscaled()`, a maximum width and height for the image.\r\n    The final image will be scaled down so it is no larger than either the width or height passed.\r\n\r\n    there is an optional fifth parameter which defaults to false which ensure that images smaller\r\n    than the maximum width and height are not scaled up.\r\n    Passing true to this parameter will scale up small images, though this may reduce quality.\r\n    \r\n`upload_unscaled()` and `upload()` can be called as many times as needed, for instance to create\r\na thumbnail in one directory, a medium image in another, and the full sized image\r\n(using `upload_unscaled()`) in an third directory.\r\n\r\n## Details\r\n\r\n### Maximum File Size\r\n\r\nThis script will allow images up to 5MB.  To change that, simply modify the if statement on line 55.\r\nThe script does not use the `MAX_FILE_SIZE` parameter of the HTML form since a malicious user can easily spoof that value.\r\n\r\n### Error Checking\r\n\r\nBoth `upload_unscaled()` and `upload()` return false on failure, or the location of the image (from the web root) on success.\r\nAny failure, be it at upload time, not an image, or a non-existent directory, will return false.\r\nCall `getError()` to return the associated error code and handle the error accordingly.\r\n\r\nPossible Errors and their codes:\r\n\r\n* 101 - File is too large\r\n* 102 - Upload failed or was interrupted\r\n* 103 - File was not uploaded\r\n* 104 - File is not an image\r\n* 105 - File is not an acceptable image (gif, jpeg, png)\r\n* 106 - File could not be saved because the directory does not exist\r\n\r\n--------------------------------------------------------------------------------\r\n\r\n## Example Usage\r\n\r\nSee `imguploader.test.php` for a more complete example:\r\n\r\n    \u003c?php\r\n    include 'imguploader.class.php';\r\n\r\n    $img = new imgUploader($_FILES['file']);\r\n    if($name = $img-\u003eupload('images/demoFile', '1000', 400,400))\r\n      echo '\u003cimg src=\"'.$name.'\" alt=\"aPicture\" /\u003e';\r\n      // will output as \u003cimg src=\"/images/demoFile/1000.jpg\" alt=\"aPicture\" /\u003e assuming file is a jpg\r\n    else\r\n      echo 'ERROR! '.$img-\u003egetError();\r\n    }\r\n    ?\u003e\r\n\r\n## Copyright\r\n\r\nCopyright 2007 Michael Diamond\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful,\r\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\r\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\nGNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License\r\nalong with this program.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimo414%2Fimgupload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimo414%2Fimgupload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimo414%2Fimgupload/lists"}