The common task when data is sent from view to controller is uploading files. Also, in this case, Yii2 provides a convenient helper to handle this task:
yii\web\UploadedFile. This class has two important methods:
getInstance() (in plural form
The first method,
getInstance(), allows us to get the file from the form's input field, while the second method,
saveAs(), as its name implies, allows us to save file input field content to the server filesystem.
Before we start with the example, it is important to create a folder that will contain the uploaded files. The best place to create this folder is at the root directory of the application. So create a folder named
uploadedfiles under the
basic/ folder. ...