@@ -39,6 +39,7 @@ type Upload struct {
3939 NotifyURL string `json:"notify_url,omitempty"`
4040 NotifyMethod string `json:"notify_method,omitempty"`
4141 CreateUuidDir bool `json:"create_uuid_dir,omitempty"`
42+ DestDirFieldName string `json:"dest_dir_field_name,omitempty"`
4243
4344 MyTlsSetting struct {
4445 InsecureSkipVerify bool `json:"insecure,omitempty"`
@@ -66,10 +67,10 @@ func (u *Upload) Provision(ctx caddy.Context) error {
6667
6768 repl := caddy .NewReplacer ()
6869
69- if u .DestDir == "" {
70+ if u .DestDir == "" && u . DestDirFieldName == "" {
7071 u .logger .Error ("Provision" ,
71- zap .String ("msg" , "no Destination Directory specified (dest_dir)" ))
72- return fmt .Errorf ("no Destination Directory specified (dest_dir)" )
72+ zap .String ("msg" , "no Destination Directory specified (dest_dir or dest_dir_field_name )" ))
73+ return fmt .Errorf ("no Destination Directory specified (dest_dir or dest_dir_field_name )" )
7374 }
7475
7576 if u .RootDir == "" {
@@ -171,6 +172,7 @@ func (u *Upload) Provision(ctx caddy.Context) error {
171172 zap .Bool ("CreateUuidDir" , u .CreateUuidDir ),
172173 zap .String ("capath" , u .MyTlsSetting .CAPath ),
173174 zap .Bool ("insecure" , u .MyTlsSetting .InsecureSkipVerify ),
175+ zap .String ("dest_dir_field_name" , u .DestDirFieldName ),
174176 )
175177
176178 return nil
@@ -239,6 +241,10 @@ func (u Upload) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp
239241 }
240242 }
241243
244+ if u .DestDirFieldName != "" {
245+ u .DestDir = r .FormValue (u .DestDirFieldName )
246+ }
247+
242248 concatDir := caddyhttp .SanitizedPathJoin (u .RootDir , u .DestDir )
243249
244250 if u .CreateUuidDir {
0 commit comments