<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                from表單文件上傳: ~~~ |-- routers | `-- router.go ~~~ ~~~ package routers import ( admin "project/admin/controllers" "github.com/astaxie/beego" ) func init() { // 固定路由也就是全匹配的路由 beego.Router("/admin/user/index", &admin.UserController{}, "*:Index") beego.Router("/admin/user/add", &admin.UserController{}, "*:Add") } |-- admin | |--controllers | `-- user.go package admin import ( "path" "strings" "github.com/astaxie/beego" ) type UserController struct { beego.Controller } func (this *UserController) Index() { this.TplName = "admin/user/index.html" } func (this *UserController) Add() { if this.Ctx.Request.Method == "GET" { this.TplName = "admin/user/add.html" } else { //image,這是一個key值,對應的是html中input type-‘file’的name屬性值 f, h, _ := this.GetFile("image") //得到文件的名稱 fileName := h.Filename arr := strings.Split(fileName, ":") if len(arr) > 1 { index := len(arr) - 1 fileName = arr[index] } //關閉上傳的文件,不然的話會出現臨時文件不能清除的情況 f.Close() //保存文件到指定的位置 //static/img,這個是文件的地址,路徑必須存在,第一個static前面不要有/ this.SaveToFile("image", path.Join("static/img/", fileName)) //跳轉到 "admin/user/index.html" this.TplName = "admin/user/index.html" } } ~~~ ~~~ |-- views | |--admin | |--user | `-- add.html ~~~ ~~~ <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>admin/user/add</title> </head> <body> this is admin/user/add <form action='{{urlfor "UserController.Add"}}' method="post" enctype="multipart/form-data"> <div class="field-content"> 文件上傳:<input name="image" type="file" /> </div> <div class="field-content"> <input type="submit" value="提交" /> </div> </form> </body> </html> ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看