我正在经典ASP中编写一个小应用程序。我有一个页面,其中有一个表单,该表单发布到第二个页面。包含在表单的POST中,是文件上传,因此需要POST方法。ASP页面未收到POST参数
尽管第二页没有看到第一页发送的任何字段。调用Request("param")
或Request.Form("param")
都只是返回空字符串。
如果我将表单上的方法从POST更改为GET(其他更改请参见NO),那么接收页面会正确拾取这些值,当然我无法进行文件上传,这是一种这个应用程序的关键部分。
在GET模式下,参数都按照预期放在网址上。在POST模式下,我启动了FireBug,并检查了我的请求的POST数据。原始形式IS发送请求中的所有值(它们按照预期在FireBug中显示),所以问题似乎在接收页面的末尾。
窗体被经由代码提交,称为从按钮与onclick="javascript:saveMinutes();"
我的形式和saveMinutes()函数被声明为如下:
<form id="frmMinutes" enctype="multipart/form-data" method="post" action="saveminutes.asp">
<table id="tblMinutes" style="width: 100%;">
<tr>
<td>
<select id="selYear" name="year" size="13" onclick="javascript:setDatePickerRange(); checkForMinutes();">
<%For lc = Year(Now) To getMinutesFirstYear() Step - 1%>
<option value="<%=lc%>" <%If lc = Year(Now) Then%>selected="selected"<%End If%>><%=lc%></option>
<%Next%>
</select>
</td>
<td>
<select id="selMonth" name="month" size="13" onclick="javascript:setDatePickerRange(); checkForMinutes();">
<%For lc = 1 To 12%>
<option value="<%=lc%>" <%If lc = Month(Now) Then%>selected="selected"<%End If%>"><%=MonthName(lc)%></option>
<%Next%>
</select>
</td>
<td style="width: 100%; padding-left: 20px;">
<table id="enterMinutes" style="width: 100%">
<tr>
<th>Topic:</th>
<td><input id="topic" name="topic" type="text" maxlength="100" field="topic" /></td>
</tr>
<tr>
<th>Presenter:</th>
<td><input id="presenter" name="presenter" type="text" maxlength="100" field="presenter" /></td>
</tr>
<tr>
<th>Date:</th>
<td><input id="mtgdate" name="mtgdate" type="text" maxlength="10" class="datepick" field="mtgdate" readonly="readonly" /></td>
</tr>
<tr>
<th style="vertical-align: top;">Files:</th>
<td style="text-align: left;">
<input id="file0" name="file0" type="file" size="35" /><span class="redEmphasis" style="margin: 0px 10px 0px 10px;">(.doc or .docx)</span><input type="button" value="+" onclick="javascript:addFileUpload();" />
</td>
</tr>
<tr>
<th style="vertical-align: top;"></th>
<td style="text-align: left; padding: 10px 0px 10px 0px;">
<input type="button" style="width: 100%" value="update minutes" onclick="javascript:saveMinutes();" />
</td>
</tr>
</table>
<span id="warnexist" class="redEmphasis" style="display: none;">The selected month already has associated minutes(). doc files take precedence over docx.</span>
</td>
</tr>
</table>
</form>
saveMinutes():
function saveMinutes() {
if($('form#frmMinutes input[type=text]').filter(function() { return $(this).val() == '' }).length > 0) {
alert('Please enter all fields.');
return;
}
if ($('form#frmMinutes input#file0').filter(function() { return !$(this).val().match(/.*\.docx?$/i) }).length > 0) {
alert('First file must be doc or docx.');
return;
}
$('form#frmMinutes input[type=file]').filter(function() { return $(this).val() == '' }).next().remove();
$('form#frmMinutes input[type=file]').filter(function() { return $(this).val() == '' }).remove();
removeDupeFiles();
// reindex file inputs after removing emptys/dupes
var fs = $('form#frmMinutes input[type=file]:gt(0)');
for (lc = 1; lc <= fs.length; lc++) {
var fid = 'file' + new String(lc);
$(fs[lc-1]).attr('id', fid).attr('name', fid);
}
$('form#frmMinutes')[0].submit();
}
如果您发布了用于提取上传文件的代码,那将比您在此处更有用。谢谢。 – 2009-12-10 18:38:47
我一直只使用Request(“param”),我完全忘记了需要解析/解码的简单参数。我有一个我下载的文件使用的类,只是没有意识到我也需要使用它作为简单的输入参数。 – eidylon 2009-12-10 19:17:10