我正在經典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