/**
* 上传文件
* */
public function img(){
$request = $this->request();
$data = $this->request()->getRequestParam();
$file = $request->getUploadedFile('file');
if(!empty($data['namedademav'])){
$name = $data['namedademav'];
$imgurl =EASYSWOOLE_ROOT.'/public/static/img/'.date("Ymd").'/'.$name;
$data = '/public/static/img/'.date("Ymd").'/'.$name;
}else{
$name = $file->getClientFilename();
$imgurl =EASYSWOOLE_ROOT.'/public/static/img/'.date("Ymd").'/'.$name;
$data = '/public/static/img/'.date("Ymd").'/'.$name;
}
$file->moveTo($imgurl);
$this->jsonData(200,$data,'上传成功');
}
引入axios
//数据
getMp3Data(){
//现在
//recorder.downloadWAV('xz');
let mp3Name = 'audio_recording_' + new Date().getTime()+'.wav';
console.log(mp3Name)
let blob = recorder.getWAVBlob();
let formData = new FormData();
formData.append('file', blob);
formData.append("namedademav", mp3Name);
let instance = axios.create({
headers: {
'Content-Type': 'multipart/form-data'
}
})
let contentType = "application/json";
instance.post('http://域名:9501/Common/img', formData).then(res => {
console.log('res---', res)
})
},
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)