eid*_*lon 1 forms parameters post input asp-classic
我正在使用Classic ASP编写一个小应用程序.我有一个页面,其中有一个表单,发布到第二页.表单的POST包括文件上传,因此需要POST方法.
第二页虽然没有看到第一页发送的任何字段.调用其中一个Request("param")或Request.Form("param")两个只返回空字符串.
如果我将我的表单上的方法从POST切换到GET(没有其他更改),那么接收页面正确地选择了值,当然我无法进行文件上传,这是此应用程序的关键部分.
在GET模式下,参数都按预期放在URL上.在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>
Run Code Online (Sandbox Code Playgroud)
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();
}
Run Code Online (Sandbox Code Playgroud)
当您的from编码为multipart时,您无法将POST值作为普通旧参数获取.它们只是多部分表单的附加部分.
要在ASP中检索上传的文件,通常需要遍历各个部分并检查每个部分以查看它是否是文件(如果是,则保存).要获取字段值,您必须添加到该循环以检查每个部分以查看它是否具有您的某个字段值的名称,然后检索该值.这在纯ASP代码中很难做到,因此很多人使用某种类型的文件上传组件,在这种情况下,字段值的检索将取决于组件.
但基本信息是:无论您正在检索文件的形式如何解析,您都必须执行相同的操作来检索字段值.
| 归档时间: |
|
| 查看次数: |
1925 次 |
| 最近记录: |