Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
haskell cgi web编程帮助_Haskell_Forms - Fatal编程技术网

haskell cgi web编程帮助

haskell cgi web编程帮助,haskell,forms,Haskell,Forms,我有一张表格: <div id="form"> <form action="upload.cgi" method="get" enctype="multipart/form-data"> <input type="file" name="file" id="file"/> <input type="submit" value="Upload"/> </form> </div>

我有一张表格:

<div id="form">
     <form action="upload.cgi" method="get" enctype="multipart/form-data">
      <input type="file" name="file" id="file"/>
      <input type="submit" value="Upload"/>
     </form>
</div>

upload.cgi是:

saveFile n =
    do cont <- liftM fromJust $ getInputFPS "file"
       let f = uploadDir ++ "/" ++ basename n
       liftIO $ writeFile f cont
       return $ paragraph << ("Saved")

uploadDir = "./uploadDirectory"        
basename = reverse . takeWhile (`notElem` "/\\") . reverse
page t b = header << thetitle << t +++ body << b


myFromJust (Just a) = a
myFromJust Nothing  = "gs"


cgiMain = do 
            mn <- getInputFilename "file"
            h <- saveFile (myFromJust mn)
            output . renderHtml $ page "Saved" h

main = runCGI $ handleErrors cgiMain
save文件n=

do cont问题是原始代码使用POST;但是在问题的HTML形式中,使用了HTMLGET。修复方法是将HTML中的
GET
更改为
POST

从它使用HTTP POST的位置:

fileForm=
形态![方法“员额”
,enctype“多部分/表格数据”]

问题是原始代码使用POST;但是在问题的HTML形式中,使用了HTMLGET。修复方法是将HTML中的
GET
更改为
POST

从它使用HTTP POST的位置:

fileForm=
形态![方法“员额”
,enctype“多部分/表格数据”]

getInputFilename
来自哪里?@Antal:最有可能的是,getInputFilename来自模块。
getInputFilename
来自哪里?@Antal:最有可能的是,getInputFilename来自模块。
fileForm =
    form ! [method "post"
           , enctype "multipart/form-data"]
             << [afile "file", submit "" "Upload"]
<form action="upload.cgi" 
      method="get" enctype="multipart/form-data">