尝试将表单发布到一个CGI脚本。

我是Haserl的新手,所以我有一个我认为相当基本的问题。我有以下HTML页面:

     <form id="upload" method="POST" enctype="multipart/form-data" action"../cgi-bin/test">
               <table>
                     <tr>
                         <td><input type=file name=uploadcsv id=uploadcsv></td>
                         <td><input name=import id=import type=submit value=Import></td>
                     </tr>
               </table>
     </form>

这个HTML文件位于我的 /var/www 文件夹中。

表单正确显示,并且使用F12工具,我可以看到POST正在被发送。 在 Firefox 的 F12 中的 "Params" 标签下,我可以看到我使用文件输入控件选择的csv文件的内容。

然而,我在cgi文件中有的测试逻辑没有被执行。

我在名为 /var/www/cgi-bin/test 的cgi脚本中有以下代码:

#!/usr/bin/haserl --shell=lua --upload-target="/uploads"
<%
print('posted')
if FORM.upload then

    print ("Status:200")
    print ("Content-Type: text/html")
    print ("inside the test")
else
    print('something went wrong')
end

%>

现在,页面上没有任何打印出来。F12中也没有看到任何错误。我认为它没有加载/运行我的cgi脚本。

我到目前为止尝试过的:

1.我已经将操作标记中的路径更改为“/cgi-bin/test”。 2.我尝试在action标记中添加扩展名“.cgi”,如“/cgi-bin/test.cgi”。注意:cgi-bin中没有任何脚本扩展名,它们都很好地工作。 3.我将尝试通过将行内服务器端代码设置为“action = '#'”将服务器端代码放入html中。但我希望最终解决方案不包含行内服务器端代码。

如有建议,将不胜感激。 谢谢。

点赞
用户4447395
用户4447395

我在 action 标签中漏掉了 = 符号。

2015-04-13 14:38:28