codice:
<%
Dim objConn, RS, SQL
set objConn=Server.CreateObject("ADODB.Connection")
objConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("/mdb-database/ventimilalegheviaggi.mdb")
%>
<%
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")
call BuildUploadRequest(RequestBin)
' definizione variabili
Dim Partenza, Ritorno, Posti, Destinazione, Note_Destinazione, Prezzo, Mezzi, Specifiche, ArrayImg, ArrayCont, ArrayValue
Partenza = UploadRequest.Item("data_partenza").Item("Value")
Ritorno = UploadRequest.Item("data_ritorno").Item("Value")
Posti = UploadRequest.Item("posti_disponibili").Item("Value")
Destinazione = UploadRequest.Item("destinazione").Item("Value")
Note_Destinazione = UploadRequest.Item("note_destinazione").Item("Value")
Prezzo = UploadRequest.Item("prezzo").Item("Value")
Mezzi = UploadRequest.Item("mezzi").Item("Value")
Specifiche = UploadRequest.Item("specifiche").Item("Value")
ArrayImg = Array(UploadRequest.Item("blob1").Item("FileName"), UploadRequest.Item("blob2").Item("FileName"), UploadRequest.Item("blob3").Item("FileName"))
ArrayCont = Array(UploadRequest.Item("blob1").Item("ContentType"), UploadRequest.Item("blob2").Item("ContentType"), UploadRequest.Item("blob3").Item("ContentType"))
ArrayValue = Array(UploadRequest.Item("blob1").Item("Value"), UploadRequest.Item("blob2").Item("Value"), UploadRequest.Item("blob3").Item("Value"))
' controllo dati
if Partenza="" or Ritorno="" or Posti="" or Destinazione="" or Note_Destinazione="" or Prezzo="" or Mezzi="" or Specifiche="" then
Session("dati") = "no"
Response.Redirect "/admin/index.asp?admin=Ins_Nostri_Viaggi.htm"
end if
'------------------------------------------------------------------------------------------------
' creazione nuova cartella immagini viaggio da query sql
SQL="SELECT IDNostro_Viaggio FROM Nostri_Viaggi;"
Dim cartella
set RS = objConn.Execute(SQL)
RS.MoveLast
cartella = RS("IDNostro_Viaggio") + 1
strNewFolder = cartella
' Percorso di destinazione, relativo o assoluto
strPath = Server.MapPath("/public/img_viaggi/")
Set objFso = Server.CreateObject("Scripting.FileSystemObject")
objFso.CreateFolder(strPath & strNewFolder)
Set objFso = Nothing
RS.Close
'------------------------------------------------------------------------------------------------
Dim ArrayPath, img
for img = 0 to Ubound(ArrayImg)
'------------------------------------------------------------------------------------------------
' SCRIPT UPLOAD
' variabili
contentType = ArrayCont(img)
filepathname = ArrayImg(img)
filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
value = ArrayValue(img)
'variabili di configurazione
Dim folder, varFolder, Est, Punto
Punto = 0
Punto = InStrRev(filepathname, ".")
Est = Right(filepathname, Len(filepathname) - Punto)
'controllo estensione
If Instr(Est, "jpg") = 0 Then
Session("ext") = "no"
Response.Redirect "/admin/index.asp?admin=Ins_Nostri_Viaggi.htm"
end if
varFolder = strNewFolder
folder = "\public\img_viaggi\"& varFolder 'directory sul server con accesso in scrittura
'fine variabili di configurazione
'Create FileSytemObject Component
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
'Create and Write to a File
Set MyFile = ScriptObject.CreateTextFile(Server.mappath(folder)&"\"&filename)
ArrayPath(img) = Server.mappath(folder)&"\"&filename
For i = 1 to LenB(value)
MyFile.Write chr(AscB(MidB(value,i,1)))
Next
MyFile.Close
' FINE SCRIPT UPLOAD
'------------------------------------------------------------------------------------------------
next
' creazione query
SQL="INSERT INTO Nostri_Viaggi(Data_Partenza, Data_Ritorno, Posti_Disponibili, Destinazione, Note_Destinazione, Prezzo, Mezzi, Specifiche_viaggio, Immagine1, Immagine2, Immagine3) VALUES('"& Partenza &"', '"& Ritorno &"', '"& Posti &"', '"& Destinazione &"', '"& Note_Destinazione &"', '"& Prezzo &"', '"& Mezzi &"', '"& Specifiche &"', '"& ArrayPath(0) &"', '"& ArrayPath(1) &"', '"& ArrayPath(2) &"');"
' esecuzione della query
set RS = objConn.Execute(SQL)
Session("Inserito") = "ok"
%>
<% Response.Redirect "/admin/index.asp?admin=Ins_Nostri_Viaggi.htm" %>
<%
'-------- sub e funzioni ----------------------
Sub BuildUploadRequest(RequestBin)
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Dictionary")
'Get an object name
Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
Pos = InstrB(Pos,RequestBin,getByteString("name="))
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
PosBound = InstrB(PosEnd,RequestBin,boundary)
If PosFile<>0 AND (PosFile<PosBound) Then
PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "FileName", FileName
Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "ContentType",ContentType
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
Else
Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
End If
UploadControl.Add "Value" , Value
UploadRequest.Add name, UploadControl
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop
End Sub
Function getByteString(StringStr)
For i = 1 to Len(StringStr)
char = Mid(StringStr,i,1)
getByteString = getByteString & chrB(AscB(char))
Next
End Function
Function getString(StringBin)
getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
Next
End Function
%>
La riga indicata dall'errore è la seguente: