Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form upload files and tekst UTF-8

Status
Not open for further replies.

avalon123

Programmer
Joined
Apr 11, 2005
Messages
4
Location
BE
Hi all,

I am currently converting a website to the UTF-8 charset. I've fixed everything so far by the following method:
Every page of the website starts with these tags:
Code:
<%@ CODEPAGE = 65001%>
<%Session.CodePage = 65001%>

Then every page gets a meta tag with the correct charset:
Code:
<head>
 <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
</head>

When saving data to the database each query is adjusted by adding a 'N' in front of every string like so:
Code:
INSERT INTO table (id, text) VALUES(" & id & ",N'" & myText & "')
Every string value in the database has a 'ntext' or 'nvarchar' type so unicode is supported.

Now all of this works fine except for forms that use the
Code:
enctype="multipart/form-data"
attribute.

I use this when I need to upload a file. When I add a text field to the form, this text isn't converted into UTF-8.

I have browsed multiple pages with information on how to do this but I can't seem to figure it out without using a tool such as 'ASP Huge File Upload',...

Can anyone tell me how this can be done without one of these tools?

Thank you in advance!
regards,
avalon
 
be aware that when using the enctype="multipart/form-data" in a form it disables the request.form object
 
Yes I know.
I use this code to capture the input of the form:
Code:
Set Post = Server.CreateObject("ActiveFile.Post")

'---- Upload file to server
cfotoFolder = c_kure_upload 
Post.upload cfotoFolder

'--- get forminfo
boek_id = Post.FormInputs("boek_id").Value
boek_naam = checkquotes(trim(Post.FormInputs("boek_naam").Value))
boek_desc = checkquotes(trim(Post.FormInputs("boek_desc").Value))

After this the values are processed to the database but that isn't relevant here. I check the contents of the textfield like this:
Code:
response.write(Post.FormInputs("boek_desc").Value)

DUDE!!! I found the problem!
After searching a bit further for Server.CreateObject("ActiveFile.Post")
I came to a website that explained how you can set the codepage for the data that is being send.
Soooo I just add
Code:
Post.CodePage = Session.CodePage
to the page and *!simsalabim!* the output is correct!

Thanks for pointing me in the right direction :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top