企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
php后端 处理方法 ``` $filepath='http://www.baidu.cn/pushid/download/20211119211504_vivo.txt'; $filename = basename($filepath); header("Content-type: text/plain"); header("Accept-Ranges: bytes"); header("Content-Disposition: attachment; filename=".$filename); header("Cache-Control: must-revalidate, post-check=0, pre-check=0" ); header("Pragma: no-cache" ); header("Expires: 0" ); readfile($filepath); exit(0); ``` 前端处理方法 只需要后端返回下载地址即可 ``` // 动态创建 a标签下载 const a = document.createElement('a'); a.setAttribute('href', d.url);// 下载的地址 a.setAttribute('download', d.name); // 设置下载名称 a.click(); ```