Steynsk
asked on
Upload file and data to database
Hi Experts,
I've got 20 documents with over 114 concurrent questions about 36 each. So I've put them in a table in my database and I've made ajax drag and drop interface so document management is easy.
The input part ready but now I have to complete the part that saves all fields into the database.
Because every document has a file upload field I guess I can't use request.from.
This is my best try:
As you can see I use Sybe Vissers pure ASP upload but I can't get lines 25 or 27 to work. I try to inject the fieldname from recordset RS into the recordset oRS.
What should be my syntax? Or am I completely wrong here?
Thanks?
I've got 20 documents with over 114 concurrent questions about 36 each. So I've put them in a table in my database and I've made ajax drag and drop interface so document management is easy.
The input part ready but now I have to complete the part that saves all fields into the database.
Because every document has a file upload field I guess I can't use request.from.
This is my best try:
<!--#INCLUDE FILE="config.asp"-->
<!--#INCLUDE FILE="requestobjects.asp"-->
<%
Server.ScriptTimeOut = 300
Response.Buffer = False
Dim oPseudoRequest
Set oPseudoRequest = new PseudoRequestDictionary
oPseudoRequest.ReadRequest()
oPseudoRequest.ReadQuerystring(Request.Querystring)
documentID= SQLEncode(oPseudoRequest.Form("docmentID"))
' Eerst uitvragen aan de database wat we voor dit document moeten opslaan
sql="SELECT DISTINCT entree_items.valuename, entree_fieldtypes.datetype FROM entree_fieldtypes INNER JOIN (entree_items INNER JOIN entree_ItemPerDocument ON entree_items.fieldtypeID = entree_ItemPerDocument.itemID) ON entree_fieldtypes.fieldtypeID = entree_items.fieldtype WHERE entree_ItemPerDocument.documentID=1;"
'response.write sql
'response.end
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL, cs
teller=0
sSQL = "SELECT * FROM entree_fase1"
Set oRS = Server.CreateObject("ADODB.RecordSet")
oRS.Open sSQL, cs, 1, 3
oRS.AddNew
Do While Not RS.EOF
if RS("datetype") = "image" then
oRS(RS("valuename")).AppendChunk oPseudoRequest.Form(RS("valuename")).Binary
else
oRS(RS("valuename")) = SQLEncode(oPseudoRequest.Form(RS("valuename")))
end if
RS.MoveNext
Loop
oRS.Update
oRS.Close
Set oRS = Nothing
response.redirect("default.asp")
Function SQLEncode(ByVal s)
SQLEncode = Cstr("" & s)
SQLEncode = Replace(SQLEncode,"'","''")
End Function
Set oPseudoRequest = Nothing
cs.Close
Set cs = Nothing
%>
As you can see I use Sybe Vissers pure ASP upload but I can't get lines 25 or 27 to work. I try to inject the fieldname from recordset RS into the recordset oRS.
What should be my syntax? Or am I completely wrong here?
Thanks?
ASKER
But will that upload my file into datsbase as a blob file? (Date type "image" in ms sql).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I understand but the files uploaded are scanned passport an id cards and should be stored more secure than basic. But maybe i should first upload them to a upload folder on the webserver and then post proces them to a blob in my db. I will search for a scrip to make this post proces work.
Maybe you have me led to an alternative solution that will solve my problem. I'll give it a try and get back to you.
Maybe you have me led to an alternative solution that will solve my problem. I'll give it a try and get back to you.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for the advise
why not? :)
how are the file upload fields named? I assume they all have some sort matching text, maybe like fileUpload1, fileUpload2, fileUpload3, etc. if thats the case, you can just loop through the Request.Form object and grab the field names that way:
Open in new window