Expand file upload request guide#467
Open
samdark wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Expands the file upload section of the request runtime guide with a complete, security-conscious example action that validates upload errors, file size, and detected MIME type, stores files outside the public directory using @runtime, generates server-side file names, and adds practical notes on PSR-7 upload pitfalls.
Changes:
- Adds prose explaining the need to check upload errors before reading/moving a file.
- Adds a full
UploadAvatarActionexample using PSR-7UploadedFileInterface,Yiisoft\Aliases\Aliases, and a PSR-17 response factory. - Adds a notes list covering non-public storage, untrusted client metadata, PHP ini limits, and multi-file uploads.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Verification
composer create-project yiisoft/app /tmp/yii-docs-upload-app --no-interactionphp -l src/Web/Profile/UploadAvatarAction.phpvendor/bin/psalm --no-cache --output-format=console src/Web/Profile/UploadAvatarAction.phpvendor/bin/phpstan analyse src/Web/Profile/UploadAvatarAction.php --level=max --no-progressUploadedFile; verified success returns 201 and a missing upload returns 400npm run buildnpx markdown-link-check src/guide/runtime/request.mdFull
npm run check-linksstill fails on existing unrelated links in translated/webserver/internal pages.