Multiple forms into one text

I’m trying to include three inputs, (.csv input file, a single line input text or multiple line text input.)
i want to write all three inputs into one text file. how do i do that? (should read the csv file and write its content)
Here’s my model and controller for .csv file


namespace app\models;

use yii\base\Model;
use yii\web\UploadedFile;

class UploadForm extends Model
    public $file;

    public function rules()
        return [
            [['file'], 'file', 'skipOnEmpty' => false, 'extensions' => 'csv'],




public function actionInput()   
        $model = new UploadForm();

        if (Yii::$app->request->isPost) {
            $model->file = UploadedFile::getInstance($model, 'file');
            $filePath = $model->file->tempName;

            if ($model->file) {           
                $model->file->saveAs('uploads/' . $model->file->baseName . '.' . $model->file->extension);
            $savedPath = Yii::getAlias('@webroot') . '/uploads/' . $model->file->baseName . '.' . $model->file->extension;

            $name = $model->file->baseName.'.'. $model->file->extension;

        return $this->render('input', ['model'=>$model]);

you have to remember, that CSV file has some structure and append data from text file may destroy csv file and later you will cannot parse that.

But to join many files to one you should read one by one and write to one.

You can use also system function and try with append operator (>>).