vue代码:
<el-col :span="6" style="margin-left: 50px">
<el-upload class="upload-demo" drag action="http://10.0.2.195:9091/upload"
name="userfile" :limit="1">
<i class="el-icon-upload"></i>
<div class="el-upload__text">将搜索的nginx日志文件拖到此处,或<em>点击上传</em></div>
</el-upload>
</el-col>
golang代码:
func UploadHandler(w http.ResponseWriter, r *http.Request)
GetFile(w, r, "../test.dat")
}
func GetFile(w http.ResponseWriter, r *http.Request, filepath string) {
fmt.Println("开始接收文件******")
//解决跨域问题
if origin := r.Header.Get("Origin"); origin != "" {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().