ASP:request.form 没有返回值? [英] ASP: request.form is not returning value?

查看:25
本文介绍了ASP:request.form 没有返回值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下表格,

<form action="contact_us.asp" method="post" enctype="multipart/form-data" name="form1" id="form1">
   <input name="firstname" type="text" id="firstname" size="30" />
   <input name="lastname" type="text" id="lastname" size="30" />
   <input type="submit" name="submit" id="submit" value="Submit" />
</form>

但是当我试图在我的 ASP 文件 contact_us.asp 中获取这些 post 变量的值时,它返回空白.代码如下:

But when I am trying to get value of these post variables in my ASP file contact_us.asp then it returns blank. Code is below:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<%

Dim FirstName, LastName, Email, Message
FirstName = request.form("firstname")
LastName = request.form("lastname")

response.write(FirstName & "OK")

%>

它只向我返回OK".Message 变量中没有任何内容?

Its returning only "OK" to me. nothing in Message variable?

请帮助我并告诉我这里有什么问题?

Please help me and tell me what's wrong here?

推荐答案

经典 ASP 不提供对处理`multipart/form-data 的内置支持.即使对于 ASP 的古老时代来说,这也是一个令人惊讶的基本缺陷,但是你打算怎么做,转向 ASP.NET?(是吗?哦.那算了.)

Classic ASP doesn't provide built-in support for working with `multipart/form-data. This is a surprisingly basic deficiency even for a language of ASP's venerable age, but what're you gonna do about it, move to ASP.NET? (Yes? oh. well never mind then.)

如果您不进行文件上传,最简单的方法是坚持使用默认的 enctype(即 application/x-www-form-urlencoded).multipart/form-data 唯一的优点是你可以把文件上传放在里面.(理论上,它还具有您可以明确指定字符编码的优势.但实际上没有浏览器会这样做.)

If you aren't doing file uploads, it's easiest just to stick with the default enctype (which is application/x-www-form-urlencoded). The only advantage of multipart/form-data is that you can put file uploads in it. (Theoretically, it would also have the advantage that you can specify character encodings definitively. But no browser actually does that.)

如果您确实需要在经典 ASP 中处理 multipart/form-data,您需要自己解析传入的请求正文,将其拆分为字段和值.或者更确切地说,使用现有的库来完成它*.

If you do need to handle multipart/form-data in Classic ASP you will need to parse the incoming request body yourself, splitting it into fields and values. Or rather, more typically, use an existing library to do it*.

那个库通常会提供单独的接口来读取上传的文件和其他表单值.这完全取代了经典 ASP Request.Form 接口的使用.您可以在哪里找到它取决于您选择的图书馆.这确实意味着,如果您想要一个可以同样响应 enctype 的表单,您必须检查类型并使用两个不同的接口之一.

That library will usually provide separate interfaces for reading the uploaded files and the other form values. This completely replaces use of the Classic ASP Request.Form interface. Exactly where you can find it depends on the library you choose. This does mean that if you want to have a form that can respond to either enctype equally you have to check the type and use one of the two different interfaces.

*:有负载.对于 示例.我不赞成这些中的任何一个......它们实际上都没有按照标准正确解析多部分,而且两者似乎对文件名安全性都有些松懈(从不在用户提交的文件下存储文件文件名!安全灾难!).但这似乎是 ASP 上传脚本课程的标准.至少,与许多人不同的是,他们不会为他们要钱.

*: There are loads. for example. I'm not endorsing either of these as such... neither of them actually parse multiparts properly as per the standard and both seem a bit lax about filename security (never store a file under the user-submitted filename! security disaster!). But that seems to be par for the course for ASP upload scripts. At least, unlike many, they're not asking money for them.

这篇关于ASP:request.form 没有返回值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆