[web-devel] help with fileField

Matt Brown matt at softmechanics.net
Mon Jan 3 03:35:47 CET 2011


Posted an example [1].  fileField is unique in two ways: it doesn't
accept a default value, and it only works with POST (i.e.
%form!method=POST).  If you submit the form via GET, the fileField
will cause the form to fail, which I assume is what you're
experiencing.  I'll make a note to describe this in the docs.

Hope this helps,
-matt

[1] https://gist.github.com/763039

2011/1/2 Knut Olav Bøhmer <bohmer at gmail.com>:
> Hi,
>
> Can anyone help me extend the "Random bananas" example from
> http://docs.yesodweb.com/book/forms/ to include a fileField, so that I
> can understand how to use the fileField.
>
> I have tried something like this:
>
> data Params = Params
>    { minNumber :: Int
>    , maxNumber :: Int
>    , singleWord :: String
>    , pluralWord :: String
>    , fileTest :: FileInfo
>    }
>
>
> paramsFormlet :: Maybe Params -> Form s m Params
> -- Same as: paramsFormlet :: Formlet s m Params
> paramsFormlet mparams = fieldsToTable $ Params
>    <$> intField "Minimum number" (fmap minNumber mparams)
>    <*> intField "Maximum number" (fmap maxNumber mparams)
>    <*> stringField "Single word" (fmap singleWord mparams)
>    <*> stringField "Plural word" (fmap pluralWord mparams)
>    <*> fileField  "test" (fmap fileTest mparams)
>
>
> I have problems understanding what's going on here.
>
>
> Regards
> --
> Knut Olav Bøhmer
>
> _______________________________________________
> web-devel mailing list
> web-devel at haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel
>



More information about the web-devel mailing list