Public Sub Save(path)
Dim streamFile, fileItem, filePath
if Right(path, 1) <> "\" then path = path & "\"
if not uploadedYet then Upload
For Each fileItem In UploadedFiles.Items
filePath = path & fileItem.FileName
Set streamFile = Server.CreateObject("ADODB.Stream")
streamFile.Type = adTypeBinary
streamFile.Open
StreamRequest.Position=fileItem.Start
StreamRequest.CopyTo streamFile, fileItem.Length
streamFile.SaveToFile filePath, adSaveCreateOverWrite
streamFile.close
Set streamFile = Nothing
fileItem.Path = filePath
'Dim fso, newFile, caseID
'Set fso = CreateObject("Scripting.FileSystemObject")
'uploadsDirVar = "C:\Inetpub\wwwroot\myweb\userfiles"
'caseID = Session("templateID")
'newFile = uploadsDirVar&"\"& templateID & fileItem.FileName
'fso.MoveFile filePath, newFile
'set fso = nothing
SQL = "SELECT * FROM myfiletable;"
Set RS = Server.CreateObject("ADODB.RecordSet")
RS.Open SQL, CS, 1, 3
RS("filename") = fileItem.FileName
RS("templateID") = Session("templateID")
RS("ContentType") = fileItem.ContentType
RS("file").AppendChunk ..............
RS.Update
RS.Close
Next
End Sub
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open sDSN
Set oPseudoRequest = new PseudoRequestDictionary
oPseudoRequest.ReadRequest()
oPseudoRequest.ReadQuerystring(Request.Querystring)
sSQL = "SELECT * FROM protocol"
Set oRS = Server.CreateObject("ADODB.RecordSet")
oRS.Open sSQL, oConn, 1, 3
oRS.AddNew
oRS("bestandsnaam") = SQLEncode(oPseudoRequest.Form("image_binary").FileName)
oRS("titel") = SQLEncode(oPseudoRequest.Form("titel"))
if not SQLEncode(oPseudoRequest.Form("URL"))= "" then
if Left(SQLEncode(oPseudoRequest.Form("URL")),7)="http://" then
oRS("URL") = SQLEncode(oPseudoRequest.Form("URL"))
else
oRS("URL") = "http://" & SQLEncode(oPseudoRequest.Form("URL"))
end if
else
oRS("URL") = ""
end if
oRS("categorie") = SQLEncode(oPseudoRequest.Form("categorie"))
oRS("nummer") = SQLEncode(oPseudoRequest.Form("nummer"))
oRS("geplaatst") = SQLEncode(oPseudoRequest.Form("geplaatst"))
oRS("bestandstype") = oPseudoRequest.Form("image_binary").ContentType
oRS("bestand").AppendChunk oPseudoRequest.Form("image_binary").Binary
oRS.Update
oRS.Close
Set oRS = Nothing
response.redirect("inhoudsopgave.asp")
Function SQLEncode(ByVal s)
SQLEncode = Cstr("" & s)
SQLEncode = Replace(SQLEncode,"'","''")
End Function
Set oPseudoRequest = Nothing
oConn.Close
Set oConn = Nothing
Set streamFile = Nothing
fileItem.Path = filePath
'costum rename
'Dim fso, newFile, caseID
'Set fso = CreateObject("Scripting.FileSystemObject")
uploadsDirVar = "C:\Inetpub\wwwroot\myweb\userfiles"
'caseID = Session("caseID")
'newFile = uploadsDirVar&"\"& templateID & fileItem.FileName
'fso.MoveFile filePath, newFile
'set fso = nothing
Set ObjStr = Server.CreateObject("ADODB.Stream")
ObjStr.Type = 1 'AdBinary
ObjStr.Open
file = uploadsDirVar&"\" & fileItem.FileName
ObjStr.LoadFromFile file
CS.Open "Provider=SQLOLEDB;Data Source=my.data.source;Initial Catalog=mycatalog; User ID=username; Password=password;"
oPreparedStatementADO.ActiveConnection = CS
cSql = "INSERT INTO entree_bestanden(file) values (?);"
oPreparedStatementADO.CommandText = cSQL
x = ObjStr.Read
oPreparedStatementADO.Parameters.Item(0) = x
set rs = oPreparedStatementADO.Execute
Next
End Sub
'onAllComplete' : function() {self.location ="PostProcessUpload.asp?caseID=<%=caseID%>";},
it would be better to just store the path of the file in the database as a pointer and then use that when you want to manipulate the file