Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to get the ENCTYPE of a form

Posted on 2000-05-02
2
524 Views
Last Modified: 2008-02-01
I have an ASP page that needs to handle two different types of forms -- the first being the default enctype: "form/url-encoded", and the second (for file uploading) being of enctype "multipart/form-data".  The problem is this:

The ASP Request object will not work if the encoding is multipart.  I can't use the Request object to tell if the encoding is (or isn't) multipart, because if it is, once I use the Request object, I can no longer do a binary read.  Also, if I attempt a binary read and the encoding is form/url-encoded, then I get a "corrupt MIME headers" error.

So the question is -- how can I tell the ENCTYPE encoding of a form without using the request object AND without using "on error resume next"

Thanks
0
Comment
Question by:knightEknight
2 Comments
 
LVL 25

Accepted Solution

by:
clockwatcher earned 50 total points
ID: 2771601
You can access the request object's ServerVariables collection.  You just can't use both the Request.Form collection and the BinaryRead method together.

The server variable you're looking for is HTTP_CONTENT_TYPE.

E.g.,

contenttype = request.servervariables("HTTP_CONTENT_TYPE")

if contenttype = "application/x-www-form-urlencoded" then
  response.write "Normal"
  x = request.form("whatever")
else
  response.write "Upload"
  x = request.binaryread(request.servervariables("content_length"))
end if
0
 
LVL 33

Author Comment

by:knightEknight
ID: 2771640
Thanks, I should have known that  :)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question