文件上传

cmlphp中提供了文件上传组件,\Cml\Vendor\UploadFile。这边对使用进行说明。

<?php
use Cml\Vendor\UploadFile;

$fileupload = new UploadFile();
$res = $fileupload->upload(CML_PROJECT_PATH . '/public/upload');//设置保存路径
if ($res) {
    $resp = $fileupload->getSuccessInfo();
    $filename = $resp[0]['savepath'].$resp[0]['savename'];    
} else {
    $error = $fileupload->getErrorInfo();
}


//后续业务处理

results matching ""

    No results matching ""