mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-20 08:27:21 +08:00
Merge pull request #8668 from yiijan/docs-small-fix
docs/guide/input-file-upload.md - small fixes [ci skip]
This commit is contained in:
@@ -5,7 +5,7 @@ Uploading files in Yii is usually done with the help of [[yii\web\UploadedFile]]
|
|||||||
file as an `UploadedFile` object. Combined with [[yii\widgets\ActiveForm]] and [models](structure-models.md),
|
file as an `UploadedFile` object. Combined with [[yii\widgets\ActiveForm]] and [models](structure-models.md),
|
||||||
you can easily implement a secure file uploading mechanism.
|
you can easily implement a secure file uploading mechanism.
|
||||||
|
|
||||||
|
|
||||||
## Creating Models <span id="creating-models"></span>
|
## Creating Models <span id="creating-models"></span>
|
||||||
|
|
||||||
Like working with plain text inputs, to upload a single file you would create a model class and use an attribute
|
Like working with plain text inputs, to upload a single file you would create a model class and use an attribute
|
||||||
@@ -48,13 +48,13 @@ In the code above, the `imageFile` attribute is used to keep the uploaded file i
|
|||||||
a `file` validation rule which uses [[yii\validators\FileValidator]] to ensure a file with extension name `png` or `jpg`
|
a `file` validation rule which uses [[yii\validators\FileValidator]] to ensure a file with extension name `png` or `jpg`
|
||||||
is uploaded. The `upload()` method will perform the validation and save the uploaded file on the server.
|
is uploaded. The `upload()` method will perform the validation and save the uploaded file on the server.
|
||||||
|
|
||||||
The `file` validator allows you to check file extensions, size, MIME type, etc. For more details, please refer to
|
The `file` validator allows you to check file extensions, size, MIME type, etc. Please refer to
|
||||||
the [Core Validators](tutorial-core-validators.md#file) section for more details.
|
the [Core Validators](tutorial-core-validators.md#file) section for more details.
|
||||||
|
|
||||||
> Tip: If you are uploading an image, you may consider using the `image` validator instead. The `image` validator is
|
> Tip: If you are uploading an image, you may consider using the `image` validator instead. The `image` validator is
|
||||||
implemented via [[yii\validators\ImageValidator]] which verifies if an attribute has received a valid image
|
implemented via [[yii\validators\ImageValidator]] which verifies if an attribute has received a valid image
|
||||||
that can be then either saved or processed using the [Imagine Extension](https://github.com/yiisoft/yii2-imagine).
|
that can be then either saved or processed using the [Imagine Extension](https://github.com/yiisoft/yii2-imagine).
|
||||||
|
|
||||||
|
|
||||||
## Rendering File Input <span id="rendering-file-input"></span>
|
## Rendering File Input <span id="rendering-file-input"></span>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user