 |
| ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

December 11th, 2003, 04:26 PM
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Binary and Text data in one form
Hia all... This is my first post... Hope someone can help me out...
basically I'm setting up a form on my website which allows people to upload a file to my webserver AND add data to an Access Database.
Below is my form code:
<form name="form1" method="post" enctype="multipart/form-data" action="savekit.asp">
<input name="txtKitName" type="text" id="txtKitName" size="30" maxlength="50">
<select name="lstModule" id="lstModule" style="width:203">
<% While (NOT getModules.EOF) %>
<option value="<%=(getModules.Fields.Item("moduleID").Valu e)%>"
<%If (Not isNull("1")) Then If (CStr(getModules.Fields.Item("moduleID").Value) = CStr("1")) Then Response.Write("SELECTED") : Response.Write("")%> >
<%=(getModules.Fields.Item("moduleName").Value)% ></option>
<% getModules.MoveNext()
Wend
If (getModules.CursorType > 0) Then
getModules.MoveFirst
Else
getModules.Requery
End If
%>
</select>
<input name="txtDescription" type="text" id="txtDescription" size="30" maxlength="200">
<input name="file" type="file" id="txtFile" size="30">
<input name="Submit" type="submit" id="Submit" value="Submit">
<input name="Reset" type="reset" id="Reset" value="Reset">
This form (possiblt because of the "multipart/form-data" part) uploads the file to the webserver with no problems - However, it's NOT sending the form data in any way that I can see to the savekit.asp page where I'm collecting the data!?
Any ideas?
Big thanx to all who can shed some light!
|
|

December 12th, 2003, 06:25 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
When you post a form with enctype=multipart/form-data, the data for the other form fields, like your description field, is included in the HTTP header along with the uploaded file, but its not a trivial task to extract it from there using ASP.
I would suggest having two forms, one with multipart/form-data for the upload and the other data without this enctype. You'll just need a bit of javasxcript on the submit button to submit both forms at once (probably best if they submit to separate asp pages).
Let me know if you absolutely must have just one form, I can probably dig out some code to guide you in extracting the data from the HTTP header, but I warn you it won't be pretty :D
hth
Phil
|
|

December 12th, 2003, 06:31 AM
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanx for the help... Although I *think* i must have one form... What do u reckon? Here is my situation...
The data (file upload) along with name and description gets sent to a page. The asp page checks to see if a file with that name already exists on the server... If it doesn't it saves the file and then enters the name, description, and Location details of the file into a database. Obviously if the file exists the user is sent back to the original page, the file is not uploaded and no information is entered into the database.
I searched the web for easier ways of doing this, but they are all too expensive for me :( So i just wrote this myself..
So do you think i'm on the right track? Any comments would be appreciated.
Thanx!
|
|

December 12th, 2003, 07:17 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
OK, you must have just one form then.
Take a look at RFC 1867 which defines multipart/form-data syntax, in particular section 6 which has an example HTTP header with both a file and other input data ( ftp://ftp.isi.edu/in-notes/rfc1867.txt).
For asp code take a look at the source for this article http://www.asp101.com/articles/jacob/scriptupload.asp. The Sub Upload() shows how to search through the binary HTTP header and read the data it contains.
hth
Phil
|
|

December 12th, 2003, 08:50 AM
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Is it at all possible to append my data form entries to the URL...
Ie, take the form data and pass it as a URL String..
E.g. ...uploadfile.asp?Name=TEST&Description=TEST2
Then on the UploadFile.asp page, I can easily extract the URL string and add that to a database entry and the binary data can be written to a file....
Or am I just being stupid?
Thanx again.
|
|

December 12th, 2003, 11:03 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Don't see why not. seems a much better way than messing around with binary data :)
Just use some js to change the action property of the form to uploadfile.asp?Name=TEST&Description=TEST2 before you submit.
Let me know how it goes...
|
|

December 12th, 2003, 11:05 AM
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I'll try it sometime over the weekend and get back to ya - Maybe it will help others in someway...
Anyway. Thanx for your help!
|
|

December 12th, 2003, 11:27 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
LOL, I'm too impatient to wait that long. I just tried it and it works just fine. Nice idea :D
|
|

December 12th, 2003, 12:00 PM
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Not bad considering i'm fairly new to ASP
|
|

December 13th, 2003, 12:08 PM
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
LOL... Hello again... Need more help
Not too familiar with Javascript - Any idea how to change the ACTION section of the form when the submit button is preSsed then?
Thanx.
Si
|
|
 |