diff --git a/Hledger/Web/Widget/AddForm.hs b/Hledger/Web/Widget/AddForm.hs
--- a/Hledger/Web/Widget/AddForm.hs
+++ b/Hledger/Web/Widget/AddForm.hs
@@ -49,14 +49,15 @@
   let  -- bindings used in add-form.hamlet
     descriptions = foldMap S.fromList [journalPayeesDeclaredOrUsed j, journalDescriptions j]
     files = fst <$> jfiles j
+    deffile = journalFilePath j
   (dateRes, dateView) <- mreq dateField dateSettings Nothing
   (descRes, descView) <- mopt textField descSettings Nothing
   (acctsRes, _)       <- mreq listField acctSettings Nothing
   (amtsRes, _)        <- mreq listField amtSettings  Nothing
-  (fileRes, fileView) <- mreq fileField' fileSettings Nothing
+  (fileRes, fileView) <- mopt fileField' fileSettings Nothing
   let
     (postingsRes, displayRows) = validatePostings acctsRes amtsRes
-    formRes = validateTransaction dateRes descRes postingsRes fileRes
+    formRes = validateTransaction deffile dateRes descRes postingsRes fileRes
   return (formRes, $(widgetFile "add-form"))
   where
     -- custom fields
@@ -86,22 +87,23 @@
     fileSettings = FieldSettings "file" Nothing Nothing (Just "file") [("class", "form-control input-lg")]
 
 validateTransaction ::
-     FormResult Day -> FormResult (Maybe Text) -> FormResult [Posting] -> FormResult FilePath
+     FilePath -> FormResult Day -> FormResult (Maybe Text) -> FormResult [Posting] -> FormResult (Maybe FilePath)
   -> FormResult (Transaction, FilePath)
-validateTransaction dateRes descRes postingsRes fileRes =
+validateTransaction deffile dateRes descRes postingsRes fileRes =
   case makeTransaction <$> dateRes <*> descRes <*> postingsRes <*> fileRes of
     FormSuccess (txn,f) -> case balanceTransaction defbalancingopts txn of
       Left e     -> FormFailure [T.pack e]
       Right txn' -> FormSuccess (txn',f)
     x -> x
   where
-    makeTransaction date mdesc postings f =
+    makeTransaction date mdesc postings mfile =
       (nulltransaction {
          tdate = date
         ,tdescription = fromMaybe "" mdesc
         ,tpostings = postings
         ,tsourcepos = (initialPos f, initialPos f)
         }, f)
+      where f = fromMaybe deffile mfile
 
 -- | Parse a list of postings out of a list of accounts and a corresponding list
 -- of amounts
diff --git a/hledger-web.cabal b/hledger-web.cabal
--- a/hledger-web.cabal
+++ b/hledger-web.cabal
@@ -5,7 +5,7 @@
 -- see: https://github.com/sol/hpack
 
 name:           hledger-web
-version:        1.27
+version:        1.27.1
 synopsis:       Web-based user interface for the hledger accounting system
 description:    A simple web-based user interface for the hledger accounting system,
                 providing a more modern UI than the command-line or terminal interfaces.
@@ -151,7 +151,7 @@
   hs-source-dirs:
       ./
   ghc-options: -Wall -Wredundant-constraints -Wincomplete-record-updates -Wincomplete-uni-patterns
-  cpp-options: -DVERSION="1.27"
+  cpp-options: -DVERSION="1.27.1"
   build-depends:
       Decimal >=0.5.1
     , aeson >=1
@@ -172,8 +172,8 @@
     , extra >=1.6.3
     , filepath
     , hjsmin
-    , hledger ==1.27.*
-    , hledger-lib ==1.27.*
+    , hledger >=1.27.1 && <1.28
+    , hledger-lib >=1.27.1 && <1.28
     , hspec
     , http-client
     , http-conduit
@@ -213,7 +213,7 @@
   hs-source-dirs:
       app
   ghc-options: -Wall -Wredundant-constraints -Wincomplete-record-updates -Wincomplete-uni-patterns
-  cpp-options: -DVERSION="1.27"
+  cpp-options: -DVERSION="1.27.1"
   build-depends:
       base >=4.14 && <4.17
     , breakpoint
@@ -234,7 +234,7 @@
   hs-source-dirs:
       test
   ghc-options: -Wall -Wredundant-constraints -Wincomplete-record-updates -Wincomplete-uni-patterns
-  cpp-options: -DVERSION="1.27"
+  cpp-options: -DVERSION="1.27.1"
   build-depends:
       base >=4.14 && <4.17
     , breakpoint
