{"id":15022004,"url":"https://github.com/php/pecl-php-uploadprogress","last_synced_at":"2025-07-02T21:07:01.087Z","repository":{"id":30620389,"uuid":"34175788","full_name":"php/pecl-php-uploadprogress","owner":"php","description":"An extension to track progress of a file upload","archived":false,"fork":false,"pushed_at":"2022-01-26T15:50:50.000Z","size":171,"stargazers_count":59,"open_issues_count":6,"forks_count":19,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-06-15T09:34:11.499Z","etag":null,"topics":["hacktoberfest","php","progress","upload"],"latest_commit_sha":null,"homepage":"http://pecl.php.net/package/uploadprogress","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php.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}},"created_at":"2015-04-18T17:39:47.000Z","updated_at":"2025-05-22T01:14:29.000Z","dependencies_parsed_at":"2022-09-01T20:12:52.894Z","dependency_job_id":null,"html_url":"https://github.com/php/pecl-php-uploadprogress","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/php/pecl-php-uploadprogress","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-php-uploadprogress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-php-uploadprogress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-php-uploadprogress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-php-uploadprogress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php","download_url":"https://codeload.github.com/php/pecl-php-uploadprogress/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-php-uploadprogress/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260823777,"owners_count":23068350,"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":["hacktoberfest","php","progress","upload"],"created_at":"2024-09-24T19:57:19.190Z","updated_at":"2025-07-02T21:07:01.062Z","avatar_url":"https://github.com/php.png","language":"C","readme":"# uploadprogress\n\nA PHP extension to track progress of a file upload, including details on the\nspeed of the upload, estimated time remaining, and access to the contents of the\nfile as it is being uploaded.\n\n## Requirements\n\nThe uploadprogress extension works on PHP 7.2+ and PHP 8. It works with\n[Apache HTTP Server][] using [mod_php][], as well as [Apache HTTP Server][],\n[nginx][], and [Caddy][] through [PHP-FPM][]. It might work on other web\nservers; let us know where you're using it.\n\n## Example\n\nCheck out the [examples][] directory for a working example that you can run on\nyour local machine.\n\n## Installation\n\nInstall uploadprogress with `pecl`:\n\n```\npecl install uploadprogress\n```\n\nIf it is not automatically added to your `php.ini` file by the `pecl` command,\nyou will need to update `php.ini` by adding the following line:\n\n``` ini\nextension=uploadprogress\n```\n\n## Documentation\n\nIn forms for which you wish to track a file upload using uploadprogress, you\nmust include a field named `UPLOAD_IDENTIFIER`.\n\nThe value of the `UPLOAD_IDENTIFIER` field may be any string. We recommend a\nrandom, unique string per upload. This extension will use this value to keep\ntrack of the upload, and you may query the extension using this identifier to\ncheck the progress of the upload.\n\nFor example, you might choose to define the `UPLOAD_IDENTIFIER` field as such:\n\n``` html\n\u003cinput type=\"hidden\" name=\"UPLOAD_IDENTIFIER\" value=\"\u003c?php echo bin2hex(random_bytes(16)); ?\u003e\"\u003e\n```\n\nThe uploadprogress extension provides two functions: `uploadprogress_get_info()`\nand `uploadprogress_get_contents()`.\n\nWhile a file is uploading, you may call these functions from a different script\nto check on the progress of the uploading file, providing the same identifier\nused as the `UPLOAD_IDENTIFIER`.\n\nFor example, you might make an HTTP `GET` request to\n`/check-progress.php?identifier=some_identifier\u0026fieldName=the_file_upload_form_field_name`.\nThe contents of `check-progress.php` might contain code like this:\n\n``` php\n$identifier = filter_input(INPUT_GET, 'identifier', FILTER_SANITIZE_STRING);\n$fieldName = filter_input(INPUT_GET, 'fieldName', FILTER_SANITIZE_STRING);\n\n$info = uploadprogress_get_info($identifier);\n$contents = uploadprogress_get_contents($identifier, $fieldName);\n```\n\n### php.ini Settings\n\n* `uploadprogress.file.filename_template`:\n\n  Set the path and pattern to which the *info* file should be written. This is\n  where we will store the data about the uploaded file, while it is being\n  uploaded. You may set it to a directory, or you may optionally use a filename\n  pattern. It defaults to `sys_get_temp_dir() . '/upt_%s.txt'`. The `%s` is\n  replaced with the value of `UPLOAD_IDENTIFIER`.\n\n* `uploadprogress.file.contents_template`:\n\n  Set the path and pattern to which the *contents* of the uploaded file should\n  be written. This allows us to read the contents of the file, while it is still\n  being uploaded. You may set it to a directory, or you may optionally use a\n  filename pattern. It defaults to `sys_get_temp_dir() . '/upload_contents_%s'`.\n  The `%s` is replaced with the value of `UPLOAD_IDENTIFIER` combined with the\n  name of the file upload form field.\n\n* `uploadprogress.get_contents`:\n\n  Set to \"On\" to enable the ability to read a file's contents while it is still\n  uploading. Defaults to \"Off.\"\n\n**NOTE:** The paths for these INI settings must be *absolute* paths. Relative\npaths will not work.\n\n#### Example php.ini\n\n``` ini\nextension=uploadprogress\nuploadprogress.get_contents=On\nuploadprogress.file.filename_template=/tmp/upt_%s.txt\nuploadprogress.file.contents_template=/tmp/upload_contents_%s\n```\n\n### uploadprogress_get_info\n\n``` php\nuploadprogress_get_info ( string $identifier ) : array\n```\n\nThe `$identifier` is the value of the form field named `UPLOAD_IDENTIFIER`.\n\nThis returns an associative array with the following keys:\n\n* `upload_id` - The value of `UPLOAD_IDENTIFIER`.\n* `fieldname` - The name of the file upload form field for this file upload.\n* `filename` - The original name of the file being uploaded.\n* `time_start` - The Unix timestamp at which the upload began.\n* `time_last` - The Unix timestamp at which this information was last updated.\n* `speed_average` - The average upload speed, in bytes.\n* `speed_last` - The last speed calculation, in bytes.\n* `bytes_uploaded` - The number of bytes uploaded so far.\n* `bytes_total` - The total number of bytes to be upload.\n* `files_uploaded` - The total number of files uploaded so far.\n* `est_sec` - The estimated number of seconds remaining until the upload is\n  complete.\n\n### uploadprogress_get_contents\n\n``` php\nuploadprogress_get_contents ( string $identifier , string $fieldName [, int $maxLength ] ) : string\n```\n\nThe `$identifier` is the value of the form field named `UPLOAD_IDENTIFIER`.\n\nThe `$fieldName` is the value of the file upload form field name.\n\nThe `$maxLength` is an optional number of bytes to read, if you wish to read\nonly the first `$maxLength` bytes of the uploading file. Otherwise, all bytes\ncurrently uploaded will be read.\n\nThis returns a string of all the bytes currently uploaded for the uploading file.\n\n## Contributing\n\nYour contributions and bug reports are highly appreciated. To contribute, fork\nand create a pull request. To report a bug use the [PHP Bug Tracking\nSystem](https://bugs.php.net/report.php?package=uploadprogress).\n\n### Building on *nix systems\n\nTo compile this extension, execute the following steps:\n\n```shell\nphpize\n./configure --enable-uploadprogress\nmake\n```\n\n### Building on Windows\n\nThe extension provides the VisualStudio V6 project file:\n\n    uploadprogress.dsp\n\nTo compile the extension you open this file using VisualStudio, select the\napropriate configuration for your installation (either \"Release_TS\" or\n\"Debug_TS\") and create `php_uploadprogress.dll`.\n\nAfter successfull compilation you have to copy the newly created\n`php_uploadprogress.dll` to the PHP extension directory (default:\n`C:\\PHP\\extensions`).\n\n### Testing\n\nYou may now run the tests with the following (on Windows, use `nmake`):\n\n```shell\nmake test TESTS=\"-n --show-diff tests\"\n```\n\nFor application testing, you can now load the extension using a php.ini directive\n\n``` ini\nextension=uploadprogress\n```\n\nThe extension should now be available, which you can test using the\n`extension_loaded()` function:\n\n``` php\nif (extension_loaded('uploadprogress')) {\n    echo \"uploadprogress loaded :)\";\n} else  {\n    echo \"something is wrong :(\";\n}\n```\n\nThe extension will also add its own block to the output of `phpinfo();`.\n\n\n[Apache HTTP Server]: https://httpd.apache.org\n[mod_php]: https://www.php.net/manual/en/install.unix.apache2.php\n[php-fpm]: https://www.php.net/fpm\n[examples]: ./examples\n[nginx]: https://nginx.org\n[caddy]: https://caddyserver.com\n","funding_links":[],"categories":["C"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp%2Fpecl-php-uploadprogress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp%2Fpecl-php-uploadprogress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp%2Fpecl-php-uploadprogress/lists"}