I am using Network.CGI (with ghc-6.2) How can I use an <INPUT TYPE="file"> element? I guess I know how to produce one: Text.Html.input ! [ Text.Html.name tag , Text.Html.thetype "file" , Text.Html.intAttr "maxlength" 10000 , Text.Html.strAttr "accept" "text/*" ] But to get to the file contents, it seems I should add Text.Html.strAttr "enctype" "multipart/form-data" to the <FORM> element, where I already have Text.Html.method "POST" but then I can't ready any values out of the environment that is provided by Network.CGI.wrapper. The environment then contains , ( "QUERY_STRING", "" ), ( "CONTENT_LENGTH", "1590" ) , ( "CONTENT_TYPE" , "multipart/form-data; boundary=---------------------------1409895718904..." ) Am I doing something wrong, HTML-wise (is it allowed to mix TYPE="file" input with other input elements in one FORM?) or is this a problem with the library? Any help appreciated. -- -- Johannes Waldmann, Tel/Fax: (0341) 3076 6479 / 6480 -- ------ http://www.imn.htwk-leipzig.de/~waldmann/ ---------
Johannes Waldmann <waldmann@imn.htwk-leipzig.de> writes:
The environment then contains
, ( "QUERY_STRING", "" ), ( "CONTENT_LENGTH", "1590" ) , ( "CONTENT_TYPE" , "multipart/form-data; boundary=---------------------------1409895718904..." )
Am I doing something wrong, HTML-wise (is it allowed to mix TYPE="file" input with other input elements in one FORM?) or is this a problem with the library?
Yes, it is allowed. Looks like the library can't parse multipart/form-data encoded content. If it's indeed the case, you lost. :-( -- Feri.
Yes, it is allowed. Looks like the library can't parse multipart/form-data encoded content. If it's indeed the case, you lost. :-(
I hope not. I'm prepared to do a bit of coding. (Just a bit :-) The CGI program should "simply" read stdin (?) and decode the parts? Possibly some of the functionality (parsing boundaries etc.) is already contained in some HTTP library? -- -- Johannes Waldmann, Tel/Fax: (0341) 3076 6479 / 6480 -- ------ http://www.imn.htwk-leipzig.de/~waldmann/ ---------
Johannes Waldmann writes:
How can I use an <INPUT TYPE="file"> element?
The Network.CGI module can't deal with that, unfortunately. You might want to take a look at the module FormData, which is (temporarily!) available here: http://peti.cryp.to/FormData.hs I'm using this module instead of Network.CGI and it works nicely. 'lookupFileField' is the function you are interested in. Hope this helps. Peter
participants (3)
-
Ferenc Wagner -
Johannes Waldmann -
Peter Simons