📜  文件上传 yii2 rest api - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:45.376000             🧑  作者: Mango

代码示例1
$uploads = UploadedFile::getInstancesByName("upfile");
    if (empty($uploads)){
        return "Must upload at least 1 file in upfile form-data POST";
    }

    // $uploads now contains 1 or more UploadedFile instances
    $savedfiles = [];
    foreach ($uploads as $file){
        $path = //Generate your save file path here;
        $file->saveAs($path); //Your uploaded file is saved, you can process it further from here
    }